Bug 85966 - fprintf and std::cerr fail on non-integer types in mult-threaded statically linked binaries using c and c++
fprintf and std::cerr fail on non-integer types in mult-threaded statically l...
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
8.0
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-03-11 11:59 EST by Jeffrey Graham
Modified: 2016-11-24 10:06 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-04-22 04:08:34 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jeffrey Graham 2003-03-11 11:59:00 EST
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 04:08:34 EDT
This works for me just fine, at least on a RHL9 system.  Please update and try
again.

Note You need to log in before you can comment on or make changes to this bug.