ACE_TAO
ACE_TAO copied to clipboard
ACE_SV_Semaphore_Complex not released at process exit via ACE_OS::exit()/ACE_OS::abort()
Version
The version of ACE and/or TAO you are using 6.5.6
Host machine and operating system
CentOS 8.0
Target machine and operating system (if different from host)
CentOS 8.0
Compiler name and version (including patch level)
gcc 8.2.1 20180905 (Red Hat 8.2.1-3)
The $ACE_ROOT/ace/config.h file
#define ACE_HAS_STANDARD_CPP_LIBRARY 1 #include "ace/config-linux.h"
If you use a link to a platform-specific file, simply state which one
The $ACE_ROOT/include/makeinclude/platform_macros.GNU file
debug=1 fast=0 optimize=0 CCFLAGS += -fpermissive buildbits=64 stdcpplib=1 stlport=0 exceptions=1 templates=automatic versioned_so=0 ssl=0 no_hidden_visibility=1 CC=gcc LDFLAGS += -lpthread -lrt
if you use a link to a platform-specific file, simply state which one (unless this isn't used in this case, e.g., with Microsoft Visual C++)
Contents of $ACE_ROOT/bin/MakeProjectCreator/config/default.features
Used by MPC when you generate your own makefiles
AREA/CLASS/EXAMPLE AFFECTED:
What example failed? What module failed to compile?
The problem effects:
Does it affect compilation, linking, or execution. Please indicate whether ACE/TAO, your application, or both are affected.
SV_Semaphore doesn't work as expected.
Synopsis
Brief description of the problem ACE_SV_Semaphore_Complex not released at process exit via ACE_OS::exit()/ACE_OS::abort().
Description
Detailed description of problem. Don't just say "
after acquiring a SV semaphore, if the process exits via exit(), abort(), ACE_OS::exit() or ACE_OS::abort(), the System V semaphore is not released (other processes can't acquire it).
Repeat by
What you did to get the error; include test program or session transcript if at all possible.
run process1 and process2 below at different terminals. process2 can't acquire the semaphore after process1 aborts.
process1:
#include <ace/SV_Semaphore_Complex.h>
#include <ace/SString.h>
#include <ace/Guard_T.h>
#include
using namespace std;
int main (int ac, char* av[]) { ACE_CString lockName("mylockname1.lock"); ACE_SV_Semaphore_Complex* lock = new ACE_SV_Semaphore_Complex(lockName.c_str());
cout << "acquiring lock" << endl; ACE_GUARD_RETURN(ACE_SV_Semaphore_Complex, guard, *lock, -1); cout << "lock acquired!" << endl;
ACE_OS::sleep(10); cout << "aborting!" << endl; ACE_OS::abort();
return 0; }
process2:
#include <ace/SV_Semaphore_Complex.h>
#include <ace/SString.h>
#include <ace/Guard_T.h>
#include
using namespace std;
int main (int ac, char* av[]) { ACE_CString lockName("mylockname1.lock"); ACE_SV_Semaphore_Complex* lock = new ACE_SV_Semaphore_Complex(lockName.c_str());
// wait until process1 aborts ACE_OS::sleep(20);
// try to acquire the semaphore cout << "acquiring lock" << endl;
// process2 blocks here indefinitely ACE_GUARD_RETURN(ACE_SV_Semaphore_Complex, guard, *lock, -1); cout << "lock acquired!" << endl; return 0; }
Sample fix/ workaround
If available None.