Yes... Infact I do have printfs that count moduleAttach's And print 'em out. So it is decremented to zero and I assume the library is unloaded. At that point, I need the registered handlers to be "unregistered" (in some way) If not, the executable has a seg fault (core dump) Makes sense? -----Original Message----- From: John [mailto:red@xxxxxxxxxxxxxxxxxxxxxxx] Sent: Thursday, April 03, 2003 7:59 PM To: redhat-devel-list@xxxxxxxxxx Subject: Re: pthread_atfork() problem on Linux9 On Thu, 3 Apr 2003 Tushar_Oza@xxxxxxxx wrote: > 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 + printf(unloading\n"); > } > > > 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! >From the man page on my system: dlclose decrements the reference count on the dynamic library handle handle. If the reference count drops to zero and no other loaded libraries use symbols in it, then the dynamic library is unloaded. If the dynamic library exports a routine named _fini, then that routine is called just before the library is unloaded. I think unloading is legitimate. Try my patch to see whether it happens. -- Please, reply only to the list. _______________________________________________ Redhat-devel-list mailing list Redhat-devel-list@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/redhat-devel-list _______________________________________________ Redhat-devel-list mailing list Redhat-devel-list@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/redhat-devel-list