From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030210 Description of problem: The following code segfaults when compiled statically. ------------------------------------------------------- #include <pthread.h> #include <iostream> pthread_mutex_t outMutex; static float i(0); void* test_1(void* arg) { pthread_mutex_lock(&outMutex); std::cerr<<"Hello "<<i++<<std::endl; pthread_mutex_unlock(&outMutex); return static_cast<void *>(NULL); } int main() { pthread_mutex_init(&outMutex,NULL); pthread_t workThreadID1; if ( 0 != pthread_create(&workThreadID1, NULL, test_1, NULL) ) std::cerr<<"Error creating workthread1"<<std::endl; if ( 0 != pthread_join(workThreadID1,NULL) ) std::cerr<<"pthread_join() failed for workthread1"<<std::endl; return 0; } My makefile: ---------------------------------------------- CXX=g++ CXXFLAGS+= -pthread LDFLAGS+=-static test: test.C $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lpthread Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1.compile the above 2.run it 3.it will seg fault 4. comment out the Makefile line that adds -static 5. compile it 6. it runs ok. Actual Results: exactly as described. Expected Results: should behave the same whether it is linked dynamically or statically Additional info: using a custom 2.4.20 kernel. gcc 3.2 20020903 (RHLinux 8.0 3.2-7) Changing the float to an int works!
This works for me just fine, at least on a RHL9 system. Please update and try again.