This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Re: Serious thread problem? [ptsekov@gmx.net: Perl 5.8.1 crash description]
Christopher Faylor wrote:
On Fri, Aug 08, 2003 at 08:12:36AM +1000, Robert Collins wrote:
On Fri, 2003-08-08 at 08:06, Christopher Faylor wrote:
----- Forwarded message from Pavel Tsekov <ptsekov@gmx.net> -----
Short description:
Now, when reentrant structures are allocated as part of the
Cygwin thread creation, these structures are allocated on
the thread stack. Newlib keeps a pointer to one of this
reentrant structures in the FILE structure.
Dang. I'm not -sure- of the posix expected behaviour for fdopen(), but
I'm pretty sure it's meant to return a process-file FILE pointer, not
thread wide.
Yes, that's my impression, too.
Sorry for being late, but i was 3 weeks away for vacation.
Here is a smaller testcase which triggers the same problem:
#include <stdio.h>
#include <pthread.h>
static FILE *fp;
static void *threadfunc (void *parm)
{
fp = fopen ("/tmp/testreent", "w");
return NULL;
}
int main(void)
{
pthread_t thread;
pthread_create (&thread, NULL, threadfunc, NULL);
pthread_join (thread, NULL);
fprintf (fp, "test");
fclose (fp);
return 0;
}
As Pavel already pointed out this is a problem with the _reent member in
the FILE structure definition.
I have no clue how this meant to work in newlib, it might be better to
disable __DYNAMIC_REENT__ again until newlib is really thread safe.
I will start a discussion at the newlib ml.
Thomas