Compiled java programs that are linked statically with gcj segfault on startup (starting with GCC 4.1.x):
# gcj -g -static --main=test -Wl,--whole-archive -lnss_files_p -lnss_dns_p -lresolv -lpthread -ldl -Wl,--no-whole-archive test.java # ./a.out Segmentation fault with test.java being i.e. public class test { public static void main( String args[] ) { System.err.println( "Hello" ); }} GDB tells me the program is crashing in: (gdb) bt #0 0x00000000 in ?? () #1 0x081e89de in pthread_create (new_thread=0x86c733c, attr=0xbffffa04, start_routine=0x808fff0 <really_start>, arg=0x74ff8) at ../.././boehm-gc/pthread_support.c:1289 #2 0x0808fee7 in _Jv_ThreadStart (thread=0x5cb18, data=0x86c7338, meth=0x808cd30 <_Jv_ThreadRun(java::lang::Thread*)>) at ../.././libjava/posix-threads.cc:488 #3 0x0808c702 in java::lang::Thread::start (this=0x5cb18) at ../.././libjava/java/lang/natThread.cc:328 #4 0x080620e4 in _Jv_CreateJavaVM (vm_args=0x0) at ../.././libjava/prims.cc:1334 #5 0x080622da in _Jv_RunMain (vm_args=0x0, klass=0x8441fc0, name=0x0, argc=1, argv=0xbffffd84, is_jar=false) at ../.././libjava/prims.cc:1355 #6 0x08062468 in _Jv_RunMain (klass=0x8441fc0, name=0x0, argc=1, argv=0xbffffd84, is_jar=false) at ../.././libjava/prims.cc:1401 #7 0x0806249b in JvRunMain (klass=0x8441fc0, argc=1, argv=0xbffffd84) at ../.././libjava/prims.cc:1407 #8 0x0804824c in main (argc=Cannot access memory at address 0x1 ) at /tmp/ccYuSF5L.i:11 Obviously, in line 1289 of pthread_support.c GC_PTHREAD_REAL_NAME is null due to the fact that it is computed using dlvsym() in line 1218. Of course(?) dlvsym() will return null if libpthread is statically linked. My quick hack around the problem was to just disable the dlvsym() variation (see attached patch). This seems to work for me. Best regards, Tom -- Summary: GC_PTHREAD_CREATE_NAME segfaults in statically linked binaries Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: boehm-gc AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aeby at graeff dot com GCC build triplet: i386-pc-linux GCC host triplet: i386-pc-linux GCC target triplet: i386-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28760