Hi,

the below patch is against current CVS HEAD, but it should be applied
to all supported branches of OpenSSL, starting with 0.9.8.

On systems running on the Windows platform, there's a DllMain function
in crypto/cryptlib.c which always calls ERR_remove_state(0) if an
application thread exits.  While this may be ok for native Windows
applications, it's wrong for applications running under Cygwin, given
that Cygwin is a POSIX environment.

Not only that compliant applications are written so that they call
ERR_remove_state by themselves right before exiting from a thread, the
gratuitous ERR_remove_state call in DllMain also potentially crashes
threaded applications.

For examples see http://bugs.python.org/issue3947 and
http://cygwin.com/ml/cygwin/2008-11/msg00341.html

The latest openssl package in the Cygwin net distribution also has this
patch applied.


Thanks,
Corinna


Index: crypto/cryptlib.c
===================================================================
RCS file: /home/cvs/cvsroot/src/openssl/crypto/cryptlib.c,v
retrieving revision 1.85
diff -u -p -r1.85 cryptlib.c
--- crypto/cryptlib.c   19 Nov 2010 00:12:01 -0000      1.85
+++ crypto/cryptlib.c   16 Mar 2011 20:45:45 -0000
@@ -744,7 +744,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, 
        case DLL_THREAD_ATTACH:
                break;
        case DLL_THREAD_DETACH:
+#ifndef __CYGWIN__
                ERR_remove_state(0);
+#endif
                break;
        case DLL_PROCESS_DETACH:
                break;


-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [email protected]

Reply via email to