Subject: guile e0c211b segfaults when linked against libgc 7.1
From: Ben Noordhuis <[email-masked]>
To: [email-masked]
Date: Sat, 12 Jan 2013 03:22:31 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

$ uname -a
Linux zoidberg 3.7.0-rc7 #17 SMP Mon Nov 26 04:46:11 CET 2012 x86_64
x86_64 x86_64 GNU/Linux

$ apt-cache show libgc-dev | grep ^Version
Version: 1:7.1-8ubuntu0.12.04.1
Version: 1:7.1-8build1

$ ./configure --prefix=$HOME/opt/guile --enable-silent-rules
--disable-shared --disable-static
<snip>

$ make -j8
<snip>
gc.c:212:1: warning: 'GC_get_free_space_divisor' defined but not used
[-Wunused-function]
<snip>
weak-set.c: In function 'move_weak_entry':
weak-set.c:180:11: warning: passing argument 1 of 'GC_base' makes
pointer from integer without a cast [enabled by default]
/usr/include/gc/gc.h:308:15: note: expected 'void *' but argument is
of type 'scm_t_bits'
weak-set.c:180:11: warning: passing argument 2 of
'GC_general_register_disappearing_link' makes pointer from integer
without a cast [enabled by default]
/usr/include/gc/gc.h:744:12: note: expected 'void *' but argument is
of type 'scm_t_bits'
<snip>
make[3]: Entering directory `/home/bnoordhuis/src/guile2/libguile'
  GEN    guile-procedures.texi
/bin/bash: line 1: 27907 Broken pipe             cat alist.doc
arbiters.doc array-handle.doc array-map.doc arrays.doc async.doc
backtrace.doc boolean.doc bitvectors.doc bytevectors.doc chars.doc
control.doc continuations.doc debug.doc deprecated.doc deprecation.doc
dynl.doc dynwind.doc eq.doc error.doc eval.doc evalext.doc expand.doc
extensions.doc feature.doc filesys.doc fluids.doc foreign.doc
fports.doc gc-malloc.doc gc.doc gettext.doc generalized-arrays.doc
generalized-vectors.doc goops.doc gsubr.doc guardians.doc hash.doc
hashtab.doc hooks.doc i18n.doc init.doc ioext.doc keywords.doc
list.doc load.doc macros.doc mallocs.doc memoize.doc modules.doc
numbers.doc objprop.doc options.doc pairs.doc ports.doc print.doc
procprop.doc procs.doc promises.doc r6rs-ports.doc random.doc
rdelim.doc read.doc root.doc rw.doc scmsigs.doc script.doc simpos.doc
smob.doc sort.doc srcprop.doc srfi-1.doc srfi-4.doc srfi-13.doc
srfi-14.doc srfi-60.doc stackchk.doc stacks.doc stime.doc strings.doc
strorder.doc strports.doc struct.doc symbols.doc threads.doc throw.doc
trees.doc uniform.doc values.doc variable.doc vectors.doc version.doc
vports.doc weak-set.doc weak-table.doc weak-vector.doc dynl.doc
posix.doc net_db.doc socket.doc regex-posix.doc
     27908 Segmentation fault      (core dumped) |
GUILE_AUTO_COMPILE=0 ../meta/uninstalled-env guild
snarf-check-and-output-texi > guile-procedures.texi

$ gdb libguile/guile libguile/core
Reading symbols from /home/bnoordhuis/src/guile2/libguile/guile...done.
[New LWP 27776]
[New LWP 27795]

warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/home/bnoordhuis/src/guile2/libguile/guile -e
(@@ (guild) main) -s /home/bnoord'.
Program terminated with signal 11, Segmentation fault.
#0  0x00002b8550ca7362 in GC_generic_malloc_inner () from /usr/lib/libgc.so.1
(gdb) bt full 10
#0  0x00002b8550ca7362 in GC_generic_malloc_inner () from /usr/lib/libgc.so.1
No symbol table info available.
#1  0x00002b8550ca4bc9 in GC_general_register_disappearing_link ()
from /usr/lib/libgc.so.1
No symbol table info available.
#2  0x00000000004767bb in register_disappearing_links
(entry=0x2889970, k=<optimized out>, v=<optimized out>,
kind=<optimized out>) at weak-table.c:133
No locals.
#3  0x0000000000476c7c in weak_table_put_x (table=0x1cf7cc0,
hash=<optimized out>, pred=0x476010 <assq_predicate>,
closure=0x2c46350, key=0x2c46350, value=0x2c43950) at weak-table.c:707
        k = 6074
        distance = 0
        size = 14051
        entries = 0x2866000
#4  0x000000000047720b in scm_c_weak_table_put_x (table=<optimized
out>, raw_hash=796165648183374467, pred=0x476010 <assq_predicate>,
closure=0x2c46350, key=<optimized out>, value=<optimized out>) at
weak-table.c:931
        t = 0x1cf7cc0
#5  0x000000000043ecbc in scm_set_source_properties_x (obj=<optimized
out>, alist=0x2c43950) at srcprop.c:209
No locals.
#6  0x0000000000472d04 in vm_regular_engine (vm=0x1d589c0,
program=0x70d128, argv=0x7fffcfb2c020, nargs=2) at vm-i-system.c:866
        subr = 0x43eca0 <scm_set_source_properties_x>
        vp = 0x1d59f50
        objects = 0x1d59f50
        stack_limit = 0x1dd9000
        current_thread = 0x1cf5e00
        registers = {{
            __jmpbuf = {7393576, -835748929747507041, 30561392, 772,
2, 2, -835748932025014113, 835784069652457631},
            __mask_was_saved = 0,
            __saved_mask = {
              __val = {17610995143953655967, 30778248, 30771648, 1, 1,
30777168, 30561392, 31297536, 30501248, 30498784, 30367232, 30778240,
33597536, 0, 47851586127694, 16}
            }
          }}
        jump_table_pointer = 0x1d25470
        jump_table = 0x1d25470
#7  0x0000000000499c86 in eval (x=0x208c070, env=0x2c46330) at eval.c:340
        argv = 0x7fffcfb2c020
        i = <optimized out>
        mx = 0x304
        proc = 0x70d128
        args = <optimized out>
        argc = 2
#8  0x0000000000499176 in eval (x=0x208df70, env=0x2c46330) at eval.c:234
        mx = 0x208df80
        proc = <optimized out>
        args = <optimized out>
        argc = <optimized out>
#9  0x0000000000499c50 in eval (x=0x20b0620, env=0x2c46630) at eval.c:338
        argv = 0x7fffcfb2c340
        i = <optimized out>
        mx = 0x20b0660
        proc = 0x1de80a0
        args = <optimized out>
        argc = 2
#10 0x0000000000499afe in prepare_boot_closure_env_for_eval
(inout_env=0x7fffcfb2c520, out_body=0x7fffcfb2c528, exps=0x20b0610,
argc=<optimized out>, proc=0x1f0a8a0) at eval.c:922
        nreq = 2
        new_env = 0x20f0a90

Upgrading libgc fixes the issue so it's presumably an API/ABI mismatch.

I get some compiler warnings after upgrading.  I'm appending them for
posterity but feel free to ignore them.

gc.c: In function 'scm_gc_stats':
gc.c:313:3: warning: 'GC_gc_no' is deprecated (declared at
/home/bnoordhuis/opt/libgc/include/gc/gc.h:76)
[-Wdeprecated-declarations]
gc.c: In function 'scm_storage_prehistory':
gc.c:625:3: warning: 'GC_all_interior_pointers' is deprecated
(declared at /home/bnoordhuis/opt/libgc/include/gc/gc.h:143)
[-Wdeprecated-declarations]
<snip>
guardians.c: In function 'scm_init_guardians':
guardians.c:358:3: warning: 'GC_java_finalization' is deprecated
(declared at /home/bnoordhuis/opt/libgc/include/gc/gc.h:169)
[-Wdeprecated-declarations]

Hope that helps.  Let me know if you want more details or want me try
out something.