public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* dlclose() vs fork()
@ 2017-03-21  9:03 Alexey Sokolov
  2017-03-21 13:42 ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Sokolov @ 2017-03-21  9:03 UTC (permalink / raw)
  To: cygwin

Hello,
If the same DLL is dlopen()ed several times, dlclose() will actually
unload the DLL only after the same number of calls to dlclose().

This works fine in cygwin, until we add fork().

It looks like in the child process the counters of inherited DLLs are
set to 1, so the first dlclose() unloads it, causing segfault for
subsequent access to the unloaded code.
https://github.com/znc/znc/issues/1385#issuecomment-288014319 has a
working minimal example of this behavior.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dlclose() vs fork()
  2017-03-21  9:03 dlclose() vs fork() Alexey Sokolov
@ 2017-03-21 13:42 ` Corinna Vinschen
  2017-03-22  8:53   ` Alexey Sokolov
  0 siblings, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2017-03-21 13:42 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 926 bytes --]

On Mar 21 09:03, Alexey Sokolov wrote:
> Hello,
> If the same DLL is dlopen()ed several times, dlclose() will actually
> unload the DLL only after the same number of calls to dlclose().
> 
> This works fine in cygwin, until we add fork().
> 
> It looks like in the child process the counters of inherited DLLs are
> set to 1, so the first dlclose() unloads it, causing segfault for
> subsequent access to the unloaded code.
> https://github.com/znc/znc/issues/1385#issuecomment-288014319 has a
> working minimal example of this behavior.

dlopen/dlclose reference counting was broken.  I applied a fix and
uploaded new dev snapshots to https://cygwin.com/snapshots/

I'm just building a 2.8.0-0.2 test release as well.


Please test.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dlclose() vs fork()
  2017-03-21 13:42 ` Corinna Vinschen
@ 2017-03-22  8:53   ` Alexey Sokolov
  2017-03-22  9:49     ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Sokolov @ 2017-03-22  8:53 UTC (permalink / raw)
  To: cygwin

Thanks Corinna for the quick fix,
The user confirmed it's working now with the snapshot.

21.03.2017 13:42, Corinna Vinschen пишет:
> On Mar 21 09:03, Alexey Sokolov wrote:
>> Hello,
>> If the same DLL is dlopen()ed several times, dlclose() will actually
>> unload the DLL only after the same number of calls to dlclose().
>>
>> This works fine in cygwin, until we add fork().
>>
>> It looks like in the child process the counters of inherited DLLs are
>> set to 1, so the first dlclose() unloads it, causing segfault for
>> subsequent access to the unloaded code.
>> https://github.com/znc/znc/issues/1385#issuecomment-288014319 has a
>> working minimal example of this behavior.
>
> dlopen/dlclose reference counting was broken.  I applied a fix and
> uploaded new dev snapshots to https://cygwin.com/snapshots/
>
> I'm just building a 2.8.0-0.2 test release as well.
>
>
> Please test.
>
>
> Thanks,
> Corinna
>


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dlclose() vs fork()
  2017-03-22  8:53   ` Alexey Sokolov
@ 2017-03-22  9:49     ` Corinna Vinschen
  0 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2017-03-22  9:49 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1129 bytes --]

On Mar 22 08:44, Alexey Sokolov wrote:
> Thanks Corinna for the quick fix,
> The user confirmed it's working now with the snapshot.
> 
> 21.03.2017 13:42, Corinna Vinschen пишет:
> > On Mar 21 09:03, Alexey Sokolov wrote:
> > > Hello,
> > > If the same DLL is dlopen()ed several times, dlclose() will actually
> > > unload the DLL only after the same number of calls to dlclose().
> > > 
> > > This works fine in cygwin, until we add fork().
> > > 
> > > It looks like in the child process the counters of inherited DLLs are
> > > set to 1, so the first dlclose() unloads it, causing segfault for
> > > subsequent access to the unloaded code.
> > > https://github.com/znc/znc/issues/1385#issuecomment-288014319 has a
> > > working minimal example of this behavior.
> > 
> > dlopen/dlclose reference counting was broken.  I applied a fix and
> > uploaded new dev snapshots to https://cygwin.com/snapshots/

Thanks for testing and feedback.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-22  8:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-21  9:03 dlclose() vs fork() Alexey Sokolov
2017-03-21 13:42 ` Corinna Vinschen
2017-03-22  8:53   ` Alexey Sokolov
2017-03-22  9:49     ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).