Bugzilla – Bug 1153239
segfault in libgc.so
Last modified: 2022-07-07 06:04:21 UTC
I build gdb on my Leap 15.1 laptop using -fuse-ld=gold, and ran into problems in the gdb.gdb testsuite. I managed to minimize the test failures to the following: ... $ cat test-scm-with-guile.c #include <libguile.h> static void * entry_point (void *arg) { return NULL; } int main (void) { scm_with_guile (entry_point, NULL); return 0; } $ gcc -I /usr/include/guile/2.0/ test-scm-with-guile.c -lguile-2.0 -fuse-ld=gold $ gdb -q ./a.out -batch -ex run -ex bt [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7344037 in GC_find_limit_with_bound (p=0x7ffff7689c20 "", up=up@entry=0, bound=bound@entry=0x0) at os_dep.c:1004 1004 GC_noop1((word)(*result)); #0 0x00007ffff7344037 in GC_find_limit_with_bound (p=0x7ffff7689c20 "", up=up@entry=0, bound=bound@entry=0x0) at os_dep.c:1004 #1 0x00007ffff7344140 in GC_find_limit (up=0, p=<optimized out>) at os_dep.c:1016 #2 GC_init_linux_data_start () at os_dep.c:463 #3 0x00007ffff734281b in GC_init () at misc.c:1169 #4 0x00007ffff7abc5eb in scm_storage_prehistory () at gc.c:619 #5 0x00007ffff7acbf8f in scm_i_init_guile (base=base@entry=0x7fffffffdae0) at init.c:389 #6 0x00007ffff7b25d88 in scm_i_init_thread_for_guile (base=0x7fffffffdae0, parent=0x0) at threads.c:833 #7 0x00007ffff7b25db9 in with_guile_and_parent (base=base@entry=0x7fffffffdae0, data=data@entry=0x7fffffffdb10) at threads.c:899 #8 0x00007ffff7342455 in GC_call_with_stack_base (fn=fn@entry=0x7ffff7b25da0 <with_guile_and_parent>, arg=arg@entry=0x7fffffffdb10) at misc.c:1949 #9 0x00007ffff7b26188 in scm_i_with_guile_and_parent (parent=<optimized out>, data=<optimized out>, func=<optimized out>) at threads.c:949 #10 scm_with_guile (func=<optimized out>, data=<optimized out>) at threads.c:955 #11 0x00000000004005d9 in main () ...
Just for completeness: the testcase works when not using "-fuse-ld=gold"?
(In reply to Michael Matz from comment #1) > Just for completeness: the testcase works when not using "-fuse-ld=gold"? Yes, using -fuse-ld=bfd works without issues.
(In reply to Tom de Vries from comment #2) > (In reply to Michael Matz from comment #1) > > Just for completeness: the testcase works when not using "-fuse-ld=gold"? > > Yes, using -fuse-ld=bfd works without issues. And, that seems no longer to be the case. On openSUSE Tumbleweed: ... $ gcc -I /usr/include/guile/3.0/ test-scm-with-guile.c -lguile-3.0 -fuse-ld=bfd $ gdb -q -batch ./a.out -ex run -ex bt Program received signal SIGSEGV, Segmentation fault. GC_find_limit_with_bound (bound=0x0, up=0, p=<optimized out>) at extra/../os_dep.c:1011 1011 GC_noop1((word)(*result)); #0 GC_find_limit_with_bound (bound=0x0, up=0, p=<optimized out>) at extra/../os_dep.c:1011 #1 0x00007ffff79f5e83 in GC_find_limit (up=0, p=<optimized out>) at extra/../os_dep.c:1023 #2 GC_init_linux_data_start () at extra/../os_dep.c:463 #3 GC_init_linux_data_start () at extra/../os_dep.c:430 #4 GC_init () at extra/../misc.c:1190 #5 GC_init () at extra/../misc.c:901 #6 0x00007ffff7ec3d6d in scm_storage_prehistory () at /usr/src/debug/guile-3.0.7-2.2.x86_64/libguile/gc.c:465 #7 scm_i_init_guile (base=0x7fffffffdba0) at /usr/src/debug/guile-3.0.7-2.2.x86_64/libguile/init.c:361 #8 0x00007ffff7f2854f in scm_i_init_guile (base=0x7fffffffdba0) at /usr/src/debug/guile-3.0.7-2.2.x86_64/libguile/init.c:358 #9 scm_i_init_thread_for_guile (base=base@entry=0x7fffffffdba0, dynamic_state=dynamic_state@entry=0x0) at /usr/src/debug/guile-3.0.7-2.2.x86_64/libguile/threads.c:570 #10 0x00007ffff7f28956 in scm_i_init_thread_for_guile (dynamic_state=0x0, base=0x7fffffffdba0) at /usr/src/debug/guile-3.0.7-2.2.x86_64/libguile/threads.c:653 #11 with_guile (base=0x7fffffffdba0, data=0x7fffffffdbd0) at /usr/src/debug/guile-3.0.7-2.2.x86_64/libguile/threads.c:638 #12 0x00007ffff79f4d57 in GC_call_with_stack_base (fn=fn@entry=0x7ffff7f288a0 <with_guile>, arg=arg@entry=0x7fffffffdbd0) at extra/../misc.c:2123 #13 0x00007ffff7f23918 in scm_i_with_guile (dynamic_state=<optimized out>, data=<optimized out>, func=<optimized out>) at /usr/src/debug/guile-3.0.7-2.2.x86_64/libguile/threads.c:688 #14 scm_with_guile (func=<optimized out>, data=<optimized out>) at /usr/src/debug/guile-3.0.7-2.2.x86_64/libguile/threads.c:694 #15 0x0000000000401148 in main () ... Interestingly, we need gdb to reproduce: ... $ ./a.out; echo $? 0 ...
On tumbleweed: ... $ cat test.c #include "gc.h" int main (void) { GC_INIT (); return 0; } ... compiled like: ... $ gcc test.c -lgc ... ... $ ./a.out; echo $? 0 ... and: ... $ gdb -q -ex run --args ./a.out Reading symbols from ./a.out... Starting program: a.out [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. GC_find_limit_with_bound (bound=0x0, up=0, p=<optimized out>) at extra/../os_dep.c:1011 1011 GC_noop1((word)(*result)); (gdb) bt #0 GC_find_limit_with_bound (bound=0x0, up=0, p=<optimized out>) at extra/../os_dep.c:1011 #1 0x00007ffff7d4de83 in GC_find_limit (up=0, p=<optimized out>) at extra/../os_dep.c:1023 #2 GC_init_linux_data_start () at extra/../os_dep.c:463 #3 GC_init_linux_data_start () at extra/../os_dep.c:430 #4 GC_init () at extra/../misc.c:1190 #5 GC_init () at extra/../misc.c:901 #6 0x000000000040112f in main () ...
Surprisingly, this is documented behaviour ( https://hboehm.info/gc/debugging.html ). I've filed an upstream PR ( https://sourceware.org/bugzilla/show_bug.cgi?id=29325 ) to handle this in the testsuite.