Statically initialising pthread attributes in dynamic dlls.
Dave Korn
dave.korn.cygwin@googlemail.com
Wed Feb 24 05:08:00 GMT 2010
On 24/02/2010 04:52, Dave Korn wrote:
> I think the answer lies here, in this comment in dll_dllcrt0_1:
>
>> /* Make sure that our exception handler is installed.
>> That should always be the case but this just makes sure.
>>
>> At some point, we may want to just remove this code since
>> the exception handler should be guaranteed to be installed.
>> I'm leaving it in until potentially after the release of
>> 1.7.1 */
>> _my_tls.init_exception_handler (_cygtls::handle_exceptions);
>
> Well, it may or may not already be installed, depending whether we got here
> via dlopen or whether this is a statically-linked DLL being initialised at
> process startup, and if it is already installed, it's not at the front of the
> list. So I figure the best bet would be to replace this call with a local
> stack-frame-based exception registration record, which we'll unlink if we
> return. IOW, just the same thing as those OS-registered SEH frames are doing
> when they unwind. I'll report back later if it works.
Yeh, that works nicely. Here's what I tested, along with a couple of extra
test cases I used to check whether exception handling was still working before
and after the dlopen call. With the current state of HEAD, the first one
works (by which I mean "prints 'sig 11' forever" and the second one fails (by
which I means reaches some sort of exit without hitting the signal handler at
all). With the attached diff, they both work (as does the original unmodified
testcase).
This is just a brain dump because I'm off to bed now, hence no change log,
and there's still commented-out stuff and inadequate commenting, but I figured
I may as well let everyone know what I found out. 'night all!
cheers,
DaveK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dlopen-seh-wrapper-fix.diff
Type: text/x-c
Size: 1195 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20100224/832b6457/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test3.cpp
URL: <http://cygwin.com/pipermail/cygwin/attachments/20100224/832b6457/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test4.cpp
URL: <http://cygwin.com/pipermail/cygwin/attachments/20100224/832b6457/attachment-0001.ksh>
-------------- next part --------------
--
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
More information about the Cygwin
mailing list