Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 85966 - fprintf and std::cerr fail on non-integer types in mult-threaded statically linked binaries using c and c++
Summary: fprintf and std::cerr fail on non-integer types in mult-threaded statically l...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 8.0
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-03-11 16:59 UTC by Jeffrey Graham
Modified: 2016-11-24 15:06 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-04-22 08:08:34 UTC


Attachments (Terms of Use)

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.


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