On Thu, 3 Apr 2003 [EMAIL PROTECTED] wrote:

> 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?

;-) If you're asking me, you're really pressing your luck. You probably
no more about this stuff than I do, but maybe I have more experience
resolving problems.

I guess that if the library's unloaded, it's not open any more. The lsof
command can tell you what files are open. You might need a sleep(600);
at some crucial point.

Have you tried gdb on this?

It works best if you compile with debugging options.

> 
> -----Original Message-----
> From: John [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 03, 2003 7:59 PM
> To: [EMAIL PROTECTED]
> Subject: Re: pthread_atfork() problem on Linux9
> 
> 
> On Thu, 3 Apr 2003 [EMAIL PROTECTED] 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
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

Reply via email to