X-Spam-Check-By: sourceware.org Message-ID: <20060403141201.67829.qmail@web53010.mail.yahoo.com> Date: Mon, 3 Apr 2006 07:12:01 -0700 (PDT) From: Gary Zablackis Subject: Re: dlopen() bug (new testcase) To: Bernhard Loos , cygwin AT cygwin DOT com In-Reply-To: <471575897@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk 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 --- Bernhard Loos wrote: > I was able to track the problem down, inserting a > call to > _my_tls.init_exception_handler > (_cygtls::handle_exceptions); > in the function dll::init() solves it. But I'm > unsure, whether it introduce > other bugs. If somebody has checked this, I could > submit a patch, if necessary. > > Bernhard Loos > Bernard, I did some further checking this weekend and have confirmed that MS LoadLibrary() installs a new exception handler (in NTDLL.DLL) which gets called when the access error caused by the call into verifyable_object_isvalid() called from pthread_key_create() called from pthread::once() ... when a dll is dlopen()ed. Evidently, this exception handler does not pass control back to the Cygwin exception handler, leaving Cygwin's state unstable. All of this can be checked in gdb by examining fs:0 inside of dlopen () before the call to LoadLibrary () and again in dll_dllcrt0 () I see three possible places to apply a patch: 1) in dll::init() [dll_init.cc]: [NOTE: this will get called whether any dll is dlopen()ed or linked in at compile time] int dll::init () { int ret = 1; _my_tls.init_exception_handler(_cygtls::handle_exceptions); ... 2) in pthread::once() [thread.cc]: [NOTE: exception handler only gets installed here for the first dlopen()ed dll] if (!once_control->state) { _my_tls.init_exception_handler(_cygtls::handle_exceptions); init_routine (); once_control->state = 1; } ... 3) or remove the test that leads directly to the problem in pthread_key_create() [thread.cc]: [NOTE: the comment indicates that this check may not be necessary, anyway] extern "C" int pthread_key_create (pthread_key_t *key, void (*destructor) (void *)) { /* The opengroup docs don't define if we should check this or not, but creation is relatively rare. */ /* REMOVE THE FOLLOWING TWO LINES: */ if (pthread_key::is_good_object (key)) return EBUSY; If you need any more information or support for getting this patched, let me know. Thank you, Gary Zablackis __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/