User account creation filtered due to spam.
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
#-8)
# icpc -V
Intel(R) C++ Compiler for 32-bit applications, Version 9.1 Build 20061103Z Package ID: l_cc_c_9.1.045
# 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
This is really a bug in glibc and not GCC. Static linking never worked correctly with pthreads anyways.