Description of problem: Attached programs report errors. Version-Release number of selected component (if applicable): glibc-2.3.2-95.3 How reproducible: Everytime. Steps to Reproduce: 1. copy sample sources to a temp dir and cd to that dir 2. export LD_LIBRARY_PATH=`pwd` 3. cc -D__USE_POSIX -D__REENTRANT -fpic -g -I. -c mylib.c -o mylib.o 4. ld -shared -o libmylib.so mylib.o 5. cc -D__USE_POSIX -D__REENTRANT -fpic -g -I. -c my2lib.c -o my2lib.o 6. ld -shared -o libmy2lib.so my2lib.o 7. gcc -o mythrtest mythrtest.c -L`pwd` -lmylib -lpthread 8. gcc -o mythrtest2 mythrtest2.c -L`pwd` -lmy2lib -lpthread 9. execute both binaries: # ./mythrtest # ./mythrtest2 Actual results: free(): invalid pointer 0xbfffba48! or Segmentation fault Expected results: No errors Additional info: Quick look at the glibc sources suggests that some members of pthread_attr_t are not initialized, which leads to freeing wild pointer.
Created attachment 97361 [details] sample libmylib.so source cc -D__USE_POSIX -D__REENTRANT -fpic -g -I. -c mylib.c -o mylib.o ld -shared -o libmylib.so mylib.o
Created attachment 97362 [details] Sample program mythrtest gcc -o mythrtest mythrtest.c -L`pwd` -lmylib -lpthread
Created attachment 97363 [details] sample libmy2lib.so source cc -D__USE_POSIX -D__REENTRANT -fpic -g -I. -c my2lib.c -o my2lib.o ld -shared -o libmy2lib.so my2lib.o
Created attachment 97364 [details] Sample program mythrtest2 gcc -o mythrtest2 mythrtest2.c -L`pwd` -lmy2lib -lpthread
There are 2 very serious bugs in your testcase: 1) never ever use ld -shared directly, always use gcc -shared or g++ -shared The GCC driver knows the details how to link properly shared libraries on each platform, which is certainly not simply running ld -shared 2) if you use any pthread functions in a library which don't have also stubs in libc.so (this is the case of mylib.c, but not my2lib.c), then you absolutely must link with -lpthread, otherwise symbol versioning cannot work properly If you do this, your testcase will work just fine. There was a bug in libpthread.so when handling libraries built against glibc 2.0, fixed in glibc-2.3.2-95.7, which will cure also your incorrectly built testcase, but that doesn't mean linking things this way will not malfunction in other places (it will). glibc-2.3.2-95.7 (well, one of its successors) will show up in U2, but closing as a NOTABUG, since this is primarily because of a buggy testcase.