www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/05/22/15:32:59

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-Id: <199905221826.NAA00916@mercury.xraylith.wisc.edu>
To: "Fifer, Eric" <EFifer AT sanwaint DOT com>
cc: cygwin AT sourceware DOT cygnus DOT com, cgf AT cygnus DOT com, dj AT cygnus DOT com
Subject: Re: fork + dlls
In-Reply-To: Your message of "Fri, 21 May 1999 13:49:21 BST."
<71E287AB0D94D111BBD600600849EC8185EDBD AT POST>
Date: Sat, 22 May 1999 13:26:31 -0500
From: Mumit Khan <khan AT xraylith DOT wisc DOT EDU>

"Fifer, Eric" <EFifer AT sanwaint DOT com> writes:
> 
> I'm having a problem that when I manually load a dll with dlopen,
> that after the fork the dll is not accessible from the child process.
> 
> There was an old thread on this topic that suggested that this should
> work, but with the following code the child fails when calling dll1_func:
> 
> forkbug1.c:

Thanks for the compact testcase!

This has been a bug since day one, and one that needs a bit of redesign
of the code in winsup/dll_init.cc to do it right. The current code there
is quite complex, and overly so in some cases, and someone who knows more 
about it needs to take a look. 

Essentially, this is what that needs to be done in dlopen:
  
  - load the library using LoadLibrary (done)
  - record the handle/name pair using a technique similar to what's done
    in DllList::recordDll, but without the _initCalled bit to avoid
    infinite loop.

after fork, the DllLoadedIterator will do the right thing and copy it into
the child's process space.

dlclose needs to take it off the list so that it doesn't get copied. Looks
like someone did start doing it by calling DllList::currentDlOpenedLib, but
it was unfinished, and in fact, buggy.

(chris, if you just comment out the call to currentDlOpenedLib in dlopen,
that bug we talked about will go away. however, it'll still be unavailable
after a fork).

I have a hack that will make it work, but it's not the correct way to do
it. I'll take this up in cygwin-developers list.

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019