69f Subj : Re: __pthread_internal_tsd_set SIGSEGV on malloc To : comp.programming.threads From : Randy Howard Date : Wed Apr 27 2005 07:02 am In article <42678a8a$0$335$cc9e4d1f@news.dial.pipex.com>, sillyzeri@gmail.com says... > I'm stumped... Compiling the following program with c++ test.cpp > -pthread OR OR g++ test.cpp -pthread, I get an identical binary. It's > slightly different if I use gcc test.cpp -pthread -lstdc++, but, both > binaries give a segmentation fault in __pthread_internal_tsd_set () from > /lib/libpthread.so.0 at the point of the malloc (I see "Hello, World!"). Why are you writing C, but compiling it as cpp? Have you tried simply renaming the file to .c and compiling with gcc to see what happens? > Note, I'm cross-compiling for i586 with OpenEmbedded. All the > OpenEmbedded packages run fine. Not familiar with it. > Does anyone know what might be causing this? > > #include > #include Nonstandard header. Try stdlib.h instead, although that probably isn't your problem. > int main() better yet, int main(void) > { > char buf[32] = "Hello, World!"; > void* buf2; Does changing the type from void * to int * or something else change it at all? > printf("%s\n", buf); > > buf2 = malloc(4); > > if (buf2 != NULL) > printf("Yay!\n"); > else > printf("%s\n", "No such luck, mister..."); > > return 0; > } Works for me. Unless you have something funky in malloc.h (or stdlib.h does some stuff differently to make pthreads happy for "OpenEmbedded"), I can't think of anything from a normal "C" point of view. . 0