From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020830 Description of problem: When compiling a simple test program and statically linking it against the pthreads library, the compile goes fine, but the program seg faults. Doing the exact same thing on an older redhat (AS2.1) and a debian system (both have an older glibc version) produces no problems - the program runs fine. Additionally, I get the same error doing this on a debian system with glibc 2.3. I'm compiling the software like so: gcc -D_REENTRANT main.c /usr/lib/libpthread.a -ggdb -lm Below is a sample program to reproduce the bug: #include <stdio.h> #include <math.h> #include <semaphore.h> #include <string.h> #include <errno.h> int main(int argc, char **argv) { sem_t sem; if (sem_init(&sem, 0, 1) == -1) { printf("error initializing semaphore: %s\n", strerror(errno)); return(1); } printf("Hello World!\n"); printf("pi = %.5f\n", 4 * atan(1.0)); sem_destroy(&sem); return(0); } Version-Release number of selected component (if applicable): rpm -qif /usr/lib/libpthread.a tells me "glibc-devel" "2.2.93 " How reproducible: Always Steps to Reproduce: 1. Compile program above with "gcc -D_REENTRANT main.c /usr/lib/libpthread.a -ggdb -lm" 2. Run it. "./a.out" 3. Watch it crash Actual Results: segmentation fault after printing 'hello world' Expected Results: expect program to run to completion. Additional info:
That's expected. You cannot statically link libpthread and dynamically libc or vice versa, both have to be dynamically linked or both have to be linked statically.
Why should this be expected behavior? I see no technical reason why one could not be linked differently than the other. I've done this with no problem against older versions of glibc with no issues... Yes, I know they're somewhat integrated but there are plenty of parts of pthreads which are seperate from the rest of glibc...