X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_20,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Message-ID: <4D7FC59F.6030901@cwilson.fastmail.fm> Date: Tue, 15 Mar 2011 16:01:35 -0400 From: Charles Wilson Reply-To: Charles Wilson User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Calling sem_wait() in DllMain( DLL_THREAD_DETACH) crashes References: <4D7FB133 DOT 7030301 AT dronecode DOT org DOT uk> <20110315190733 DOT GA23825 AT ednor DOT casa DOT cgf DOT cx> In-Reply-To: <20110315190733.GA23825@ednor.casa.cgf.cx> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 3/15/2011 3:07 PM, Christopher Faylor wrote: > On Tue, Mar 15, 2011 at 06:34:27PM +0000, Jon TURNEY wrote: >> >> I've come across a problem whilst trying to run the twisted test suite, where >> some tests just cause python to segfault. It seems to be the same issue with >> libcrypto as reported in [2],[3] > Actually you aren't supposed to be able to call anything you like here and > it isn't clear why a POSIX/UNIX/Linux program would be relying on DllMain. There are cases where cygwin-ish code does win32-ish things, like login.exe, or the PyWin32 extensions for Python-on-Windows(and cygwin). Maybe twisty uses PyWin32? However, it does seem that python (or one of its extensions) is doing something it shouldn't. From http://msdn.microsoft.com/en-us/library/ms682583%28v=vs.85%29.aspx > The entry-point function should perform only simple initialization > or termination tasks. It must not call the LoadLibrary or LoadLibraryEx > function (or a function that calls these functions), because this may > create dependency loops in the DLL load order. This can result in a DLL > being used before the system has executed its initialization code. > Similarly, the entry-point function must not call the FreeLibrary > function (or a function that calls FreeLibrary) during process > termination, because this can result in a DLL being used after the > system has executed its termination code. > > Because Kernel32.dll is guaranteed to be loaded in the process > space when the entry-point function is called, calling functions in > Kernel32.dll does not result in the DLL being used before its > initialization code has been executed. Therefore, the entry-point > function can call functions in Kernel32.dll that do not load other DLLs. > For example, DllMain can create synchronization objects such as critical > sections and mutexes, and use TLS. Unfortunately, there is not a > comprehensive list of safe functions in Kernel32.dll. > > Windows 2000: Do not create a named synchronization object in > DllMain because the system will then load an additional DLL. > > Calling functions that require DLLs other than Kernel32.dll may > result in problems that are difficult to diagnose. For example, > calling User, Shell, and COM functions can cause access violation > errors, because some functions load other system components. > Conversely, calling functions such as these during termination can > cause access violation errors because the corresponding component may > already have been unloaded or uninitialized. > > Because DLL notifications are serialized, entry-point functions > should not attempt to communicate with other threads or processes. > Deadlocks may occur as a result. -- Chuck -- 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