Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT cygwin DOT com Delivered-To: mailing list cygwin-developers AT cygwin DOT com X-Authentication-Warning: atacama.four-d.de: mail set sender to using -f Date: Thu, 1 Aug 2002 16:48:09 +0200 (=?ISO-8859-1?Q?Westeurop=E4ische_Sommerzeit?=) From: Thomas Pfaff To: cygwin-developers AT cygwin DOT com Subject: RFC: TLS problem Message-ID: X-X-Sender: pfaff AT antarctica DOT intern DOT net MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII While tracking down the problems with a threaded perl i recognized a problem with TLS that is probably the reason for the forked child crash: The TLS is not synced between parent and child. If i run my test program #define WIN32_LEAN_AND_MEAN #include #include int main(void) { int w_key = TlsAlloc (); TlsSetValue (w_key, (void*) 0x10); switch (fork()) { case -1: return 0; case 0: printf ("child : %p\n", TlsGetValue (w_key)); break; default: wait (NULL); printf ("parent: %p\n", TlsGetValue (w_key)); } return 0; } i get child : 0x0 parent: 0x10 Since perl use TLS (pthread keys to be true, but this will be mapped to win32 TLS) to store the perl interpreter reference the child will crash because the reference is NULL. IMHO the are two possible solutions: 1. Synchronize the win32 TLS array between parent and child. 2. Create a cygwin only solution that will use its own tls array like CGFs experimental TLS implementation. I would prefer solution 1 because it will more general, consider that a cygwin app can use the WIN32 TLS functions and not the pthread ones. Thomas