Bug#212048: g++-3.3: a statically compiled c++ binary which references syslog(3) SEGFAULTs on an exception
Package: g++-3.3
Version: 1:3.3.2-0pre4
Severity: important
Tags: sid
When compiled with "g++ static.cc -o static -static", this program segfaults
on execution. I spent 6 hours narrowing this down as it is a very unlikely
bug. Some speculation below.
#include <syslog.h>
#include <iostream>
using namespace std;
int func()
{
syslog(LOG_INFO,"","");
}
int main(int argc, char **argv)
{
try {
throw(10);
}
catch(...) {
cout<<"Smells like a 10"<<endl;
}
}
Commenting out syslog solves the problem. The backtrace:
#0 0x0808c7e0 in get_cie_encoding ()
#1 0x0808cc3a in classify_object_over_fdes ()
#2 0x0808daa9 in init_object ()
#3 0x0808d1e8 in search_object ()
#4 0x0808d298 in _Unwind_Find_registered_FDE ()
#5 0x0808d79c in _Unwind_Find_FDE ()
#6 0x0808b314 in uw_frame_state_for ()
#7 0x0808b84f in uw_init_context_1 ()
#8 0x0808bad8 in _Unwind_RaiseException ()
#9 0x0807d999 in __cxa_throw ()
#10 0x08048253 in main ()
The following may be interesting:
$ nm -C static.o
00000110 t global constructors keyed to func()
The problem exists even when syslog is, in fact, never called. So I suspect
the problem must lie in these 'global constructors keyed to func()'. In the
glibc-2.3.2 sources we find:
/* Define the lock. */
__libc_lock_define_initialized (static, syslog_lock)
Which may well lead to a global initializer.
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux d800.ds9a.nl 2.6.0-test4 #2 Sat Aug 23 15:40:41 CEST 2003 i686
Locale: LANG=C, LC_CTYPE=
Versions of packages g++-3.3 depends on:
ii gcc-3.3 1:3.3.2-0pre4 The GNU C compiler
ii gcc-3.3-base 1:3.3.2-0pre4 The GNU Compiler Collection (base
ii libc6 2.3.2-7 GNU C Library: Shared libraries an
ii libstdc++5-3.3-dev 1:3.3.2-0pre4 The GNU Standard C++ Library v3 (d
-- no debconf information
Reply to: