| delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-developers-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-developers-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sources.redhat.com/ml/cygwin-developers/> |
| List-Post: | <mailto:cygwin-developers AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-developers-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
| 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 <tpfaff AT gmx DOT net> using -f |
| Date: | Thu, 1 Aug 2002 16:48:09 +0200 (=?ISO-8859-1?Q?Westeurop=E4ische_Sommerzeit?=) |
| From: | Thomas Pfaff <tpfaff AT gmx DOT net> |
| To: | cygwin-developers AT cygwin DOT com |
| Subject: | RFC: TLS problem |
| Message-ID: | <Pine.WNT.4.44.0208011634350.331-100000@algeria.intern.net> |
| X-X-Sender: | pfaff AT antarctica DOT intern DOT net |
| MIME-Version: | 1.0 |
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 <windows.h>
#include <stdio.h>
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |