Péter Szabó
2014-01-24 02:14:16 UTC
Hi,
I'm getting a segmentation fault for i386, but it works for x86_64:
$ /tmp/dietlibc-0.33/bin-i386/diet gcc -m32 -s -O2 -W -Wall pj.c -lpthread
$ ./a.out
Segmentation fault (core dumped)
https://dl.dropboxusercontent.com/u/635918/dietlibc/a.out
$ /tmp/dietlibc-0.33/bin-i386/diet gcc -m32 -g -o a.out.debug pj.c -lpthread
$ ./a.out
Segmentation fault (core dumped)
https://dl.dropboxusercontent.com/u/635918/dietlibc/a.out.debug
Source file (pj.c):
#include <pthread.h>
/*__thread*/
int a;
static int *a_in_other_thread;
static void *thread_func(void *arg) {
(void)arg;
a_in_other_thread = &a;
return (void *)0;
}
int main(void) {
pthread_t thread;
void *thread_retval;
int *a_in_main_thread;
if (pthread_create (&thread, (pthread_attr_t *)0, thread_func, (void *)0))
return 2;
a_in_main_thread = &a;
if (pthread_join (thread, &thread_retval))
return 3;
return (a_in_other_thread == a_in_main_thread);
}
Am I using it correctly? Can you reproduce the problem?
Thanks,
Péter
I'm getting a segmentation fault for i386, but it works for x86_64:
$ /tmp/dietlibc-0.33/bin-i386/diet gcc -m32 -s -O2 -W -Wall pj.c -lpthread
$ ./a.out
Segmentation fault (core dumped)
https://dl.dropboxusercontent.com/u/635918/dietlibc/a.out
$ /tmp/dietlibc-0.33/bin-i386/diet gcc -m32 -g -o a.out.debug pj.c -lpthread
$ ./a.out
Segmentation fault (core dumped)
https://dl.dropboxusercontent.com/u/635918/dietlibc/a.out.debug
Source file (pj.c):
#include <pthread.h>
/*__thread*/
int a;
static int *a_in_other_thread;
static void *thread_func(void *arg) {
(void)arg;
a_in_other_thread = &a;
return (void *)0;
}
int main(void) {
pthread_t thread;
void *thread_retval;
int *a_in_main_thread;
if (pthread_create (&thread, (pthread_attr_t *)0, thread_func, (void *)0))
return 2;
a_in_main_thread = &a;
if (pthread_join (thread, &thread_retval))
return 3;
return (a_in_other_thread == a_in_main_thread);
}
Am I using it correctly? Can you reproduce the problem?
Thanks,
Péter