[Ace-users] [ace-bugs] ACE_Process_Mutex acquisition fails after fork and exit of parent

Glasser, Nathan nglasser at cantata.com
Mon Sep 17 13:13:25 CDT 2007


    ACE VERSION: 5.5.1

    HOST MACHINE and OPERATING SYSTEM:
        Linux Red Hat ES/AS 3.0 & 4.0 and
        Solaris 9, 10

    TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
    COMPILER NAME AND VERSION (AND PATCHLEVEL):

    THE $ACE_ROOT/ace/config.h FILE

==================================================

/* There is supposed to be another way to turn this on,
   but I can't find it, and this should suffice. */
/* Tag the ACE symbols with version info to avoid name collisions. */
#define ACE_HAS_VERSIONED_NAMESPACE 1

#define ACE_HAS_STANDARD_CPP_LIBRARY 1
#define ACE_NTRACE 1
#define ACE_NLOGGING 1
#define ACE_DEFINES_DEFAULT_WIN32_SECURITY_ATTRIBUTES 1

#ifdef _WIN32
#include "config_win32.h"
#endif

#ifdef __linux__
#include "config_linux.h"
#endif

#if defined (__SUNPRO_CC)
//#include "config_sunos5.7.h"
#include "config_sunos5.8.h"
//#include "config_sunos5.9.h"
#endif

/* Get around bug for VS.NET 2003 */
#if (_MSC_VER >= 1300 && _MSC_VER < 1400)
#undef ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT
#endif

==================================================

    THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE
        for Linux:    platform_linux.GNU
        for Solaris:  platform_sunos5_sunc++.GNU

    CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
    (used by MPC when you generate your own makefiles):

    AREA/CLASS/EXAMPLE AFFECTED:

    DOES THE PROBLEM AFFECT:
        COMPILATION?
        LINKING?
        EXECUTION?
            Yes.
        OTHER (please specify)?

    SYNOPSIS:
        ACE_Process_Mutex acquisition fails after fork and exit of
parent.

    DESCRIPTION:
        If you statically declare a named ACE_Process_Mutex object on
        Linux or Solaris, then fork(), and then exit the parent process,
        the child process will be unable to acquire the mutex.
        It fails with EINVAL.

    REPEAT BY:
        Here is a small test program that illustrates the problem.

==================================================

#include "ace/ACE.h"
#include "ace/Process_Mutex.h"

ACE_Process_Mutex foo_mutex("test_mut");

main()
{
    if (fork() > 0)
    {
        printf("Main process exiting\n");
        exit(0);
    }

    printf("About to acquire...\n");
    sleep(5);
    if (foo_mutex.tryacquire())
        perror("Acquire failed");
    else
    {
        printf("Acquire succeeded\n");
        foo_mutex.release();
    }
}

==================================================

    SAMPLE FIX/WORKAROUND:



More information about the Ace-users mailing list