Subject: bug#25386: calling gc too often triggers a crash

From: Linas Vepstas <[email-masked]>
Date: Sun, 8 Jan 2017 15:55:38 -0600

Since above works so swimmingly in the bove example, I tried it in a
production system.  Calling gc shortly before thread exit results in a
crash, always the same crash, always in under 20 minutes:

guile: hashtab.c:137: vacuum_weak_hash_table: Assertion `removed <= len'
failed.
Aborted

again, this is for guile -v
guile (GNU Guile) 2.0.11
Packaged by Debian (2.0.11-deb+1-10)

Perhaps this is fixed in 2.0.13 ???

guile: hashtab.c:137: vacuum_weak_hash_table: Assertion `removed <= len' failed.

Thread 1416 "guile" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffe7b7fe700 (LWP 29883)]
0x00007ffff749e428 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
54      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff749e428 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff74a002a in __GI_abort () at abort.c:89
#2  0x00007ffff7496bd7 in __assert_fail_base (fmt=<optimized out>,
    assertion=assertion@entry=0x7ffff7b5f7a2 "removed <= len",
    file=file@entry=0x7ffff7b5f798 "hashtab.c", line=line@entry=137,
    function=function@entry=0x7ffff7b5ff60 "vacuum_weak_hash_table")
    at assert.c:92
#3  0x00007ffff7496c82 in __GI___assert_fail (
    assertion=0x7ffff7b5f7a2 "removed <= len",
    file=0x7ffff7b5f798 "hashtab.c", line=137,
    function=0x7ffff7b5ff60 "vacuum_weak_hash_table") at assert.c:101
#4  0x00007ffff7ac3108 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#5  0x00007ffff7ac31af in ?? ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#6  0x00007ffff7ac5b1c in scm_c_hook_run ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#7  0x00007ffff7207ff5 in GC_try_to_collect_inner ()
   from /usr/lib/x86_64-linux-gnu/libgc.so.1
#8  0x00007ffff72082aa in GC_try_to_collect_general ()
   from /usr/lib/x86_64-linux-gnu/libgc.so.1
#9  0x00007ffff720838d in GC_gcollect ()
   from /usr/lib/x86_64-linux-gnu/libgc.so.1
#10 0x00007ffff7ab9109 in scm_gc ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#11 0x00007ffff7b3402b in ?? ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#12 0x00007ffff7aab107 in scm_call_1 ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#13 0x00007ffff7b34093 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#14 0x00007ffff7aab21e in scm_call_3 ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#15 0x00007ffff7b34093 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#16 0x00007ffff7aab283 in scm_call_4 ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#17 0x00007fffefb90d79 in
opencog::SchemeEval::do_eval(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&) (
    this=0x7ffe74000980, expr=...)
    at /home/ubuntu/src/atomspace/opencog/guile/SchemeEval.cc:564
#18 0x00007fffefb90e2a in opencog::SchemeEval::c_wrap_eval(void*) (
    p=0x7ffe74000980)
    at /home/ubuntu/src/atomspace/opencog/guile/SchemeEval.cc:493
#19 0x00007ffff7aa158a in ?? ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#20 0x00007ffff7b34093 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#21 0x00007ffff7aab283 in scm_call_4 ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#22 0x00007ffff7aa1d21 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#23 0x00007ffff7aa1e05 in scm_c_with_continuation_barrier ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#24 0x00007ffff72198e7 in GC_call_with_gc_active ()
   from /usr/lib/x86_64-linux-gnu/libgc.so.1
#25 0x00007ffff7b21c01 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#26 0x00007ffff7213952 in GC_call_with_stack_base ()
   from /usr/lib/x86_64-linux-gnu/libgc.so.1
#27 0x00007ffff7b21fe8 in scm_with_guile ()
   from /usr/lib/x86_64-linux-gnu/libguile-2.0.so.22
#28 0x00007fffefb90eae in
opencog::SchemeEval::eval_expr(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&) (
    this=0x7ffe74000980, expr=...)
    at /home/ubuntu/src/atomspace/opencog/guile/SchemeEval.cc:465
#29 0x00007fffe386cc86 in opencog::GenericShell::eval_loop (
    this=0x7ffe4c001380)
    at /home/ubuntu/src/opencog/opencog/cogserver/shell/GenericShell.cc:446
#30 0x00007fffee768c80 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#31 0x00007ffff78396ba in start_thread (arg=0x7ffe7b7fe700)
    at pthread_create.c:333
#32 0x00007ffff756f82d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109