Subject: Stuck in wait-condition-variable

From: Christopher Baines <[email-masked]>
Date: Wed, 15 Nov 2023 11:44:34 +0000

I seem to have got Guile stuck in wait-condition-variable.

This is Guile 3.0.9 (specifically
/gnu/store/x4m56h5qkim0pnvx6vgvp541mrdwdrah-guile-3.0.9/bin/guile).

Here's some strace output.

futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f52a1eb6480, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f52a1eb6480, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x7f52a1eb6480, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1eb6480, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f5295cf7bc0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f52a1495af4, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1700032632, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)

I think a key thing here is that all the calls to
wait-condition-variable are done with a timeout that is (current-time)
plus a few seconds, and 1700032632 is hours behind the current time of
(1700048795), so I think that's an indication that the program is stuck
inside wait-condition-variable.

Here's a backtrace from GDB:

(gdb) bt
#0  0x00007f52a188416a in __futex_abstimed_wait_common () from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6
#1  0x00007f52a1886abc in pthread_cond_timedwait@@GLIBC_2.3.2 () from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6
#2  0x00007f52a1e315a5 in scm_pthread_cond_timedwait (cond=<optimized out>, mutex=<optimized out>, wt=<optimized out>)
    at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/threads.c:1618
#3  0x00007f52a1e34eb3 in block_self (queue=((#<smob thread 7f52a1411020>) #<smob thread 7f52a1411020>), mutex=mutex@entry=0x7f5295cf7bc0, 
    waittime=waittime@entry=0x7f5249ffa690) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/threads.c:315
#4  0x00007f52a1e37707 in timed_wait (waittime=0x7f5249ffa690, current_thread=0x7f52a1495900, c=0x7f5295d2ed50, m=0x7f5295cf7bc0, kind=SCM_MUTEX_STANDARD)
    at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/threads.c:1371
#5  scm_timed_wait_condition_variable (cond=#<smob condition-variable 7f5295d2f380>, mutex=#<smob mutex 7f5295d2f3a0>, timeout=<optimized out>)
    at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/threads.c:1429
#6  0x00007f52a1e3d390 in vm_regular_engine (thread=0x7f52a1495900) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/vm-engine.c:972
#7  0x00007f52a1e4adb5 in scm_call_n (proc=<optimized out>, argv=<optimized out>, nargs=0) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/vm.c:1615
#8  0x00007f52a1db1b3e in scm_call_with_unblocked_asyncs (proc=#<program 7f52a1487fe0>) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/async.c:406
#9  0x00007f52a1e3d390 in vm_regular_engine (thread=0x7f52a1495900) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/vm-engine.c:972
#10 0x00007f52a1e4adb5 in scm_call_n (proc=<optimized out>, argv=<optimized out>, nargs=0) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/vm.c:1615
#11 0x00007f52a1e370f3 in really_launch (d=0x7f52a1486f60) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/threads.c:782
#12 0x00007f52a1db3e1a in c_body (d=0x7f5249ffad80) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/continuations.c:430
#13 0x00007f52a1e3d390 in vm_regular_engine (thread=0x7f52a1495900) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/vm-engine.c:972
#14 0x00007f52a1e4adb5 in scm_call_n (proc=<optimized out>, argv=<optimized out>, nargs=2) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/vm.c:1615
#15 0x00007f52a1db55ca in scm_call_2 (proc=<optimized out>, arg1=<optimized out>, arg2=<optimized out>)
    at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/eval.c:503
#16 0x00007f52a1e5c092 in scm_c_with_exception_handler.constprop.0 (type=#t, handler_data=handler_data@entry=0x7f5249ffad10, 
    thunk_data=thunk_data@entry=0x7f5249ffad10, thunk=<optimized out>, handler=<optimized out>)
    at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/exceptions.c:170
#17 0x00007f52a1e37e1f in scm_c_catch (tag=<optimized out>, body=<optimized out>, body_data=<optimized out>, handler=<optimized out>, 
    handler_data=<optimized out>, pre_unwind_handler=<optimized out>, pre_unwind_handler_data=0x7f52a132b500)
    at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/throw.c:168
#18 0x00007f52a1db6396 in scm_i_with_continuation_barrier (pre_unwind_handler=0x7f52a1db60b0 <pre_unwind_handler>, pre_unwind_handler_data=0x7f52a132b500, 
    handler_data=0x7f5249ffad80, handler=0x7f52a1dbcba0 <c_handler>, body_data=0x7f5249ffad80, body=0x7f52a1db3e10 <c_body>)
    at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/continuations.c:368
#19 scm_c_with_continuation_barrier (func=<optimized out>, data=<optimized out>) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/continuations.c:464
#20 0x00007f52a1e37049 in with_guile (base=0x7f5249ffae08, data=0x7f5249ffae30) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/threads.c:649
#21 0x00007f52a1d177fa in GC_call_with_stack_base () from /gnu/store/k1ha4n9v8d7myiiszvl2ic7xnb56l219-libgc-8.2.2/lib/libgc.so.1
#22 0x00007f52a1e30c5d in scm_i_with_guile (dynamic_state=<optimized out>, data=0x7f52a1486f60, func=0x7f52a1e37080 <really_launch>)
    at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/threads.c:692
#23 launch_thread (d=0x7f52a1486f60) at /tmp/guix-build-guile-3.0.9.drv-0/guile-3.0.9/libguile/threads.c:791
#24 0x00007f52a18873aa in start_thread () from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6
#25 0x00007f52a1907f7c in clone3 () from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6