Fwd: possible bug in dietlibc-0.33 -lpthread

Péter Szabó <[email protected]> Fri, 24 Jan 2014 03:14:16 +0100
Newsgroups gmane.linux.lib.dietlibc
Message-ID <CAAAOz0_cHyj4niAyEApv5qOe4NFAvaLr-mfuPV9vh0xUHdAyJg@mail.gmail.com>
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