This is the mail archive of the libc-hacker@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Patch]: SIGSEGV: exceptions with thread specific data


> 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);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]