This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34297] New: static linking with pthreads stl runtime error
- From: "thehighhat at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Nov 2007 23:49:52 -0000
- Subject: [Bug c++/34297] New: static linking with pthreads stl runtime error
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Tracking down a problem with a much more rigorous codebase. Using this
contrived example to demonstrate the issue:
#include <iostream>
using namespace std;
// static link this with pthreads to test
int main()
{
// this will exit cleanly
cout << "std::cout" << endl;
// this will segfault, why?
cerr << "std::cerr" << endl;
return 0;
}
On default setup of RHEL 4, 32bit host and compiler, compile as:
g++ test.C
works fine. Then statically link:
g++ -static test.C
works fine. Now use -pthread option:
g++ -pthread test.C
works fine. Then statically link:
g++ -static -pthread test.C
problem! The compile and link are both successful. However, when executing
the code, it segfaults.
This does *not* happen on 64bit host and 64bit compiler.
It does happen on 64bit host and 32bit compile (-m32 option).
Note that std::cout does *not* cause segfault, but std::cerr does.
This happens also with g++ 4.1.1 on RHEL4, again in 32bit.
Also, using Intel compilers 9.1 version shows the exact same pathology.
Example
icpc -static -pthread test.C
----------
I cannot determine the cause, nor can I find a workaround.
Perhaps there is an issue with the STL in 32bit in GCC?
--------- details
# g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-8)
# icpc -V
Intel(R) C++ Compiler for 32-bit applications, Version 9.1 Build 20061103Z
Package ID: l_cc_c_9.1.045
Copyright (C) 1985-2006 Intel Corporation. All rights reserved.
# uname -a
Linux hostname.domainname.com 2.6.9-55.0.2.ELsmp #1 SMP Tue Jun 12 17:59:08 EDT
2007 i686 i686 i386 GNU/Linux
--
Summary: static linking with pthreads stl runtime error
Product: gcc
Version: 3.4.6
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: thehighhat at gmail dot com
GCC host triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34297