[LCP]FW: pthread_atfork() problem on Linux9

Tushar_Oza at Dell.com Tushar_Oza at Dell.com
Fri Apr 4 09:01:02 UTC 2003


-----Original Message-----
From: Oza, Tushar 
Sent: Thursday, April 03, 2003 6:40 PM
Subject: pthread_atfork() problem on Linux9


Hello,

A brief description of the problem we see on Linux 9 follows:

Please let me know if any of you have seen this problem or know how to
tackle it!


I have a "mylib.so" that calls:

_init()
{
   pthread_atfork(NULL, ParentHdlr, ChildHdlr);
}

_fini()
{
   // do nothing
}


Another executable mytest.c does the following:

main()
{
  void *libHandle = NULL;

  libHandle = dlopen("mylib.so", RTLD_NOW);
  // dlopen() call succeeds so I have not included my error checking code
here
  dlclose(libHandle);
  libHandle = NULL;
  ...
  printf("\n In mytest.c: Before fork \n");

  if ((pid = fork()) < 0)
  {
     printf("Fork failed\n");
  }

  printf("Something after fork\n");
}


Note that the fork() is called after the dlclose()
And mytest.c is NOT linked with mylib.so

The problem is mytest.c causes a SEGMENTATION FAULT on Linux9. Seems to work
fine on Linux 8 and below.

We suspect that the atfork() handler functions registered at _init are lost
And that causes the seg fault before the fork() since it cant find the
handlers anymore as the library has been closed.

Any help is appreciated. Thanks!

         tushar




More information about the linuxCprogramming mailing list