This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Statically initialising pthread attributes in dynamic dlls.


On Tue, Feb 23, 2010 at 05:28:06PM +0000, Andrew West wrote:
>On 23/02/2010 10:00, Andrew West wrote:
>> With the code I'm testing against, the exception handler isn't called 
>> in the library and it bombs out there. :(
>> The dll initialisation stuff calls '_cygtls::init_exception_handler' 
>> but it doesn't insert it because it finds it's already
>> there ( from test.exe I guess ), or at least it doesn't hit my break 
>> point in '_cygtls::reset_fault' during the call
>> to pthread_mutexattr_init.
>>
>
>Further to this ( possibly instead of this ). When the code reaches this 
>point inside the call to pthread_mutexattr_init;
>
>if ((*object)->magic != magic)
>
>Shouldn't the SEH contain the cytls exception handler as the first item 
>in the list? I seem to have 4 things before it;
>
>(gdb) info w32 selector
>Selector $cs
><snip>

>0x03b: base=0x7ffdf000 limit=0x00000fff 32-bit Data (Read/Write, Exp-up)
><snip>
>(gdb) x/wx 0x7ffdf000
>0x7ffdf000:     0x0022c628
>(gdb) x/2wx 0x0022c628
>0x22c628:       0x0022c8d4      0x7c90e920

FYI, there's a better way to look at these:

set $el=(exception_list**)0x7ffdf000
print **$el
print *($el->prev)

(and I suspect there's an even better way to decode $fs:0 that I've
forgotten)

>(gdb) x/x 0x7c90e920
>0x7c90e920 <strchr+275>:        0x83ec8b55
>(gdb) x/2wx 0x0022c8d4
>0x22c8d4:       0x0022cb7c      0x7c90e920
>(gdb) x/x 0x7c90e920
>0x7c90e920 <strchr+275>:        0x83ec8b55
>(gdb) x/2wx 0x0022cb7c
>0x22cb7c:       0x0022cbe4      0x7c90e920
>(gdb) x/x 0x7c90e920
>0x7c90e920 <strchr+275>:        0x83ec8b55
>(gdb) x/2wx 0x0022cbe4
>0x22cbe4:       0x0022ce68      0x7c839ad8
>(gdb) x/x 0x7c839ad8
>0x7c839ad8 <ValidateLocale+688>:        0x83ec8b55
>(gdb) x/2wx 0x0022ce68
>0x22ce68:       0x0022ffe0      0x61028d70
>(gdb) x/x 0x61028d70
>0x61028d70 
><_ZN7_cygtls17handle_exceptionsEP17_EXCEPTION_RECORDP15_exception_listP8_CONTEXTPv>: 
>0x57e58955
>(gdb) x/2wx 0x0022ce68
>0x22ce68:       0x0022ffe0      0x61028d70
>(gdb) x/x 0x61028d70
>0x61028d70 
><_ZN7_cygtls17handle_exceptionsEP17_EXCEPTION_RECORDP15_exception_listP8_CONTEXTPv>: 
>0x57e58955
>(gdb) x/x 0x0022ffe0
>0x22ffe0:       0xffffffff
>
>No idea if I'm even in the right area with this, or am I looking at this 
>list in the wrong order... and should the cygtls exception handler 
>really be in the list twice?

I never saw the cygwin exception handler on the list twice when I was
debugging this.  That isn't supposed to happen and I don't see how it
could happen unless Windows is doing it since the code in
_cygtls::init_exception_handler is supposed to prevent that and, if it
was on the list twice bad stuff happened.

That actually looks like a typo above since you seem to have typed the
same address twice.

Anyway, I've revisited this code, just like I knew I would, and have
added YA in a long series of tweaks which seems to fix your particular
problem.  The fix is in the latest snapshot.

Thanks for checking into this so deeply and thanks for the simple test
case.

cgf

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]