This is the mail archive of the
libc-hacker@cygnus.com
mailing list for the glibc project.
Re: [Patch]: SIGSEGV: exceptions with thread specific data
- To: wmglo@dent.med.uni-muenchen.de (Wolfram Gloger)
- Subject: Re: [Patch]: SIGSEGV: exceptions with thread specific data
- From: hjl@varesearch.com (H.J. Lu)
- Date: Tue, 16 Mar 1999 14:05:30 -0800 (PST)
- Cc: jason@cygnus.com, libc-hacker@cygnus.com (GNU C Library)
> glibc's malloc is most definitely thread-safe, as long as it
> is properly initialized. Do the malloc() requests for exception
> handling happen very early, maybe even before glibc's constructors
> have run ?
>
> I'll have more time to look into this later this week. If someone
> can send me the latest test-case, I'd be grateful
>
>
Here it is.
--
H.J. Lu (hjl@gnu.org)
---
----
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
char *ptr;
pthread_key_t key;
void *main_thr(void * x)
{
int i;
// here linuxthreads allocate through calloc thread specific data
pthread_setspecific(key, "asd");// try move after catch
ptr = malloc (300);
pthread_setspecific(key, NULL);
}
int
main()
{
pthread_t t_id;
pthread_key_create(&key, NULL);
pthread_create(&t_id, NULL, main_thr, NULL);
pthread_join(t_id, NULL);
pthread_key_delete(key); // try disable
free (ptr);
exit(0);
}