Bug 85966

Summary: fprintf and std::cerr fail on non-integer types in mult-threaded statically linked binaries using c and c++
Product: [Retired] Red Hat Linux Reporter: Jeffrey Graham <jgraham>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-04-22 08:08:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jeffrey Graham 2003-03-11 16:59:00 UTC
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!

Comment 1 Ulrich Drepper 2003-04-22 08:08:34 UTC
This works for me just fine, at least on a RHL9 system.  Please update and try
again.