X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Tue, 23 Feb 2010 19:44:03 -0500 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: Statically initialising pthread attributes in dynamic dlls. Message-ID: <20100224004403.GA24591@ednor.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4B825D76 DOT 6000105 AT gmail DOT com> <4B82C093 DOT 7010001 AT gmail DOT com> <4B83A727 DOT 3030101 AT gmail DOT com> <4B841026 DOT 1000905 AT gmail DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4B841026.1000905@gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 > >0x03b: base=0x7ffdf000 limit=0x00000fff 32-bit Data (Read/Write, Exp-up) > >(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 : 0x83ec8b55 >(gdb) x/2wx 0x0022c8d4 >0x22c8d4: 0x0022cb7c 0x7c90e920 >(gdb) x/x 0x7c90e920 >0x7c90e920 : 0x83ec8b55 >(gdb) x/2wx 0x0022cb7c >0x22cb7c: 0x0022cbe4 0x7c90e920 >(gdb) x/x 0x7c90e920 >0x7c90e920 : 0x83ec8b55 >(gdb) x/2wx 0x0022cbe4 >0x22cbe4: 0x0022ce68 0x7c839ad8 >(gdb) x/x 0x7c839ad8 >0x7c839ad8 : 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