Subject: Recent async changes in master cause segfault
From: <[email-masked]>
To: [email-masked]
Date: Wed, 9 Nov 2016 11:18:27 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

The test-suite/standalone/test-guild-compile test is segfaulting.  Git bisecting between the 2.1.4 release and HEAD shows

# first bad commit: [c957ec7ab0f0a028910dc737e12191f7bdc1ca93] Use atomics for async interrupts

gcc --version
gcc (Debian 4.9.2-10) 4.9.2

uname -mr
3.16.0-4-amd64 x86_64

A pretty much up-to-date Debian Jessie system.

Collecting a core dump and displaying all backtraces is:

(gdb) thr apply all bt

Thread 3 (Thread 0x7fb574b2f740 (LWP 12971)):
#0  0x00007fb573bff893 in select () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007fb5746d1e6b in do_std_select (args=0x7fffcf4c8de0) at threads.c:1752
#2  0x00007fb5738d1ba3 in GC_do_blocking_inner (data=<optimized out>, context=<optimized out>) at pthread_support.c:1141
#3  0x00007fb5738d32be in GC_with_callee_saves_pushed (fn=<optimized out>, arg=<optimized out>) at mach_dep.c:273
#4  0x00007fb5738cb69c in GC_do_blocking (fn=<optimized out>, fn@entry=0x7fb5746d1e50 <do_std_select>, client_data=<optimized out>, client_data@entry=0x7fffcf4c8de0)
    at misc.c:1657
#5  0x00007fb5746d292a in scm_without_guile (func=0x7fb5746d1e50 <do_std_select>, data=0x7fffcf4c8de0) at threads.c:848
#6  0x00007fb5746d2ab5 in scm_std_select (nfds=4, nfds@entry=0, readfds=0x7fffcf4c8e10, readfds@entry=0x0, writefds=writefds@entry=0x0, exceptfds=exceptfds@entry=0x0, 
    timeout=timeout@entry=0x7fffcf4c8ed0) at threads.c:1796
#7  0x00007fb5746d33e3 in scm_std_sleep (secs=<optimized out>) at threads.c:1912
#8  0x00007fb5746b3940 in scm_sleep (i=<optimized out>) at scmsigs.c:636
#9  0x00007fb5746e0a26 in vm_regular_engine (thread=0x4, vp=0xd78d80, registers=0x0, resume=260) at vm-engine.c:832
#10 0x00007fb5746e64f6 in scm_call_n (proc=0x7fb574b5a030, argv=argv@entry=0x7fffcf4c90f8, nargs=nargs@entry=1) at vm.c:1248
#11 0x00007fb574668ac7 in scm_primitive_eval (exp=exp@entry=0xe6c870) at eval.c:654
#12 0x00007fb574668b23 in scm_eval (exp=0xe6c870, module_or_state=module_or_state@entry=0xd8c750) at eval.c:688
#13 0x00007fb5746b448d in scm_shell (argc=9, argv=0x7fffcf4c9728) at script.c:454
#14 0x00007fb57467f85d in invoke_main_func (body_data=0x7fffcf4c95d0) at init.c:339
#15 0x00007fb5746627ea in c_body (d=0x7fffcf4c9510) at continuations.c:429
#16 0x00007fb5746e0a26 in vm_regular_engine (thread=0x4, vp=0xd78d80, registers=0x0, resume=2) at vm-engine.c:832
#17 0x00007fb5746e64f6 in scm_call_n (proc=0xdca4a0, proc@entry=0xd4ced0, argv=argv@entry=0x0, nargs=nargs@entry=0) at vm.c:1248
#18 0x00007fb5746679f9 in scm_call_0 (proc=proc@entry=0xd4ced0) at eval.c:473
#19 0x00007fb5746d3ea7 in catch (tag=tag@entry=0x404, thunk=0xdca4a0, handler=0x7fb574662ac0 <c_handler>, pre_unwind_handler=0xdca3e0) at throw.c:135
#20 0x00007fb5746d42d5 in scm_catch_with_pre_unwind_handler (key=key@entry=0x404, thunk=<optimized out>, handler=<optimized out>, pre_unwind_handler=<optimized out>)
    at throw.c:249
#21 0x00007fb5746d438f in scm_c_catch (tag=tag@entry=0x404, body=body@entry=0x7fb5746627e0 <c_body>, body_data=body_data@entry=0x7fffcf4c9510, 
    handler=handler@entry=0x7fb574662ac0 <c_handler>, handler_data=handler_data@entry=0x7fffcf4c9510, 
    pre_unwind_handler=pre_unwind_handler@entry=0x7fb574662920 <pre_unwind_handler>, pre_unwind_handler_data=0xdd3bc0) at throw.c:370
#22 0x00007fb574662e20 in scm_i_with_continuation_barrier (body=body@entry=0x7fb5746627e0 <c_body>, body_data=body_data@entry=0x7fffcf4c9510, 
    handler=handler@entry=0x7fb574662ac0 <c_handler>, handler_data=handler_data@entry=0x7fffcf4c9510, 
    pre_unwind_handler=pre_unwind_handler@entry=0x7fb574662920 <pre_unwind_handler>, pre_unwind_handler_data=0xdd3bc0) at continuations.c:367
#23 0x00007fb574662eb5 in scm_c_with_continuation_barrier (func=<optimized out>, data=<optimized out>) at continuations.c:463
#24 0x00007fb5746d248c in with_guile_and_parent (base=0x7fffcf4c9570, data=0x7fffcf4c95a0) at threads.c:786
#25 0x00007fb5738cb6ca in GC_call_with_stack_base (fn=0xfffffffffffffdfe, fn@entry=0x7fb5746d2440 <with_guile_and_parent>, arg=0x7fffcf4c8e10, arg@entry=0x7fffcf4c95a0)
    at misc.c:1553
#26 0x00007fb5746d28b8 in scm_i_with_guile_and_parent (parent=<optimized out>, data=data@entry=0x7fffcf4c95a0, func=func@entry=0x7fb57467f840 <invoke_main_func>)
    at threads.c:829
#27 scm_with_guile (func=func@entry=0x7fb57467f840 <invoke_main_func>, data=data@entry=0x7fffcf4c95d0) at threads.c:835
#28 0x00007fb57467f9f2 in scm_boot_guile (argc=argc@entry=9, argv=argv@entry=0x7fffcf4c9728, main_func=main_func@entry=0x400a50 <inner_main>, closure=closure@entry=0x0)
    at init.c:322
#29 0x00000000004008f0 in main (argc=9, argv=0x7fffcf4c9728) at guile.c:101

Thread 2 (Thread 0x7fb572588700 (LWP 12986)):
#0  0x00007fb573ed7add in read () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007fb574670ef7 in read_finalization_pipe_data (data=0x7fb572587a80) at finalizers.c:199
#2  0x00007fb5738d1ba3 in GC_do_blocking_inner (data=<optimized out>, context=<optimized out>) at pthread_support.c:1141
#3  0x00007fb5738d32be in GC_with_callee_saves_pushed (fn=<optimized out>, arg=<optimized out>) at mach_dep.c:273
#4  0x00007fb5738cb69c in GC_do_blocking (fn=<optimized out>, fn@entry=0x7fb574670ee0 <read_finalization_pipe_data>, client_data=<optimized out>, 
    client_data@entry=0x7fb572587a80) at misc.c:1657
#5  0x00007fb5746d292a in scm_without_guile (func=0x7fb574670ee0 <read_finalization_pipe_data>, data=0x7fb572587a80) at threads.c:848
#6  0x00007fb574671307 in finalization_thread_proc (unused=<optimized out>) at finalizers.c:212
#7  0x00007fb5746627ea in c_body (d=0x7fb572587e60) at continuations.c:429
#8  0x00007fb5746e0a26 in vm_regular_engine (thread=0x5, vp=0xd78c80, registers=0x1, resume=2) at vm-engine.c:832
#9  0x00007fb5746e64f6 in scm_call_n (proc=0xd7d700, proc@entry=0xd4ccd0, argv=argv@entry=0x0, nargs=nargs@entry=0) at vm.c:1248
#10 0x00007fb5746679f9 in scm_call_0 (proc=proc@entry=0xd4ccd0) at eval.c:473
#11 0x00007fb5746d3ea7 in catch (tag=tag@entry=0x404, thunk=0xd7d700, handler=0x7fb574662ac0 <c_handler>, pre_unwind_handler=0xd7d660) at throw.c:135
#12 0x00007fb5746d42d5 in scm_catch_with_pre_unwind_handler (key=key@entry=0x404, thunk=<optimized out>, handler=<optimized out>, pre_unwind_handler=<optimized out>)
---Type <return> to continue, or q <return> to quit---
    at throw.c:249
#13 0x00007fb5746d438f in scm_c_catch (tag=tag@entry=0x404, body=body@entry=0x7fb5746627e0 <c_body>, body_data=body_data@entry=0x7fb572587e60, 
    handler=handler@entry=0x7fb574662ac0 <c_handler>, handler_data=handler_data@entry=0x7fb572587e60, 
    pre_unwind_handler=pre_unwind_handler@entry=0x7fb574662920 <pre_unwind_handler>, pre_unwind_handler_data=0xdd3bc0) at throw.c:370
#14 0x00007fb574662e20 in scm_i_with_continuation_barrier (body=body@entry=0x7fb5746627e0 <c_body>, body_data=body_data@entry=0x7fb572587e60, 
    handler=handler@entry=0x7fb574662ac0 <c_handler>, handler_data=handler_data@entry=0x7fb572587e60, 
    pre_unwind_handler=pre_unwind_handler@entry=0x7fb574662920 <pre_unwind_handler>, pre_unwind_handler_data=0xdd3bc0) at continuations.c:367
#15 0x00007fb574662eb5 in scm_c_with_continuation_barrier (func=<optimized out>, data=<optimized out>) at continuations.c:463
#16 0x00007fb5746d248c in with_guile_and_parent (base=0x7fb572587ec0, data=0x7fb572587ef0) at threads.c:786
#17 0x00007fb5738cb6ca in GC_call_with_stack_base (fn=0xfffffffffffffe00, fn@entry=0x7fb5746d2440 <with_guile_and_parent>, arg=0x7fb572587a80, arg@entry=0x7fb572587ef0)
    at misc.c:1553
#18 0x00007fb5746d28b8 in scm_i_with_guile_and_parent (parent=<optimized out>, data=<optimized out>, func=<optimized out>) at threads.c:829
#19 scm_with_guile (func=<optimized out>, data=<optimized out>) at threads.c:835
#20 0x00007fb573ed10a4 in start_thread (arg=0x7fb572588700) at pthread_create.c:309
#21 0x00007fb573c0662d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7fb5719d0700 (LWP 12987)):
#0  __GI___pthread_mutex_lock (mutex=0x0) at ../nptl/pthread_mutex_lock.c:66
#1  0x00007fb5746d2b55 in scm_pthread_mutex_lock (mutex=<optimized out>) at threads.c:1833
#2  0x00007fb5746593a3 in scm_system_async_mark_for_thread (proc=0x1065900, thread=<optimized out>) at async.c:147
#3  0x00007fb5746b32c3 in signal_delivery_thread (data=<optimized out>) at scmsigs.c:186
#4  0x00007fb5746e0a26 in vm_regular_engine (thread=0x0, vp=0xd78a80, registers=0x7fb5749413e0 <atomics_lock>, resume=2) at vm-engine.c:832
#5  0x00007fb5746e64f6 in scm_call_n (proc=0x106bf80, proc@entry=0xd4cad0, argv=argv@entry=0x0, nargs=nargs@entry=0) at vm.c:1248
#6  0x00007fb5746679f9 in scm_call_0 (proc=proc@entry=0xd4cad0) at eval.c:473
#7  0x00007fb5746d3ea7 in catch (tag=tag@entry=0x404, thunk=0x106bf80, handler=0x0, pre_unwind_handler=0x4) at throw.c:135
#8  0x00007fb5746d42d5 in scm_catch_with_pre_unwind_handler (key=key@entry=0x404, thunk=<optimized out>, handler=<optimized out>, pre_unwind_handler=<optimized out>)
    at throw.c:249
#9  0x00007fb5746d438f in scm_c_catch (tag=tag@entry=0x404, body=body@entry=0x7fb5746b3210 <signal_delivery_thread>, body_data=body_data@entry=0x0, 
    handler=handler@entry=0x7fb5746d4540 <scm_handle_by_message>, handler_data=handler_data@entry=0x7fb5747026b5, pre_unwind_handler=pre_unwind_handler@entry=0x0, 
    pre_unwind_handler_data=0x0) at throw.c:370
#10 0x00007fb5746d439e in scm_internal_catch (tag=tag@entry=0x404, body=body@entry=0x7fb5746b3210 <signal_delivery_thread>, body_data=body_data@entry=0x0, 
    handler=handler@entry=0x7fb5746d4540 <scm_handle_by_message>, handler_data=handler_data@entry=0x7fb5747026b5) at throw.c:379
#11 0x00007fb5746d2d3c in really_spawn (d=0x7fffcf4c8c80) at threads.c:951
#12 0x00007fb5746627ea in c_body (d=0x7fb5719cfe60) at continuations.c:429
#13 0x00007fb5746e0a26 in vm_regular_engine (thread=0x0, vp=0xd78a80, registers=0x7fb5749413e0 <atomics_lock>, resume=2) at vm-engine.c:832
#14 0x00007fb5746e64f6 in scm_call_n (proc=0x106bfe0, proc@entry=0xd4cad0, argv=argv@entry=0x0, nargs=nargs@entry=0) at vm.c:1248
#15 0x00007fb5746679f9 in scm_call_0 (proc=proc@entry=0xd4cad0) at eval.c:473
#16 0x00007fb5746d3ea7 in catch (tag=tag@entry=0x404, thunk=0x106bfe0, handler=0x7fb574662ac0 <c_handler>, pre_unwind_handler=0x106bfa0) at throw.c:135
#17 0x00007fb5746d42d5 in scm_catch_with_pre_unwind_handler (key=key@entry=0x404, thunk=<optimized out>, handler=<optimized out>, pre_unwind_handler=<optimized out>)
    at throw.c:249
#18 0x00007fb5746d438f in scm_c_catch (tag=tag@entry=0x404, body=body@entry=0x7fb5746627e0 <c_body>, body_data=body_data@entry=0x7fb5719cfe60, 
    handler=handler@entry=0x7fb574662ac0 <c_handler>, handler_data=handler_data@entry=0x7fb5719cfe60, 
    pre_unwind_handler=pre_unwind_handler@entry=0x7fb574662920 <pre_unwind_handler>, pre_unwind_handler_data=0xdd3bc0) at throw.c:370
#19 0x00007fb574662e20 in scm_i_with_continuation_barrier (body=body@entry=0x7fb5746627e0 <c_body>, body_data=body_data@entry=0x7fb5719cfe60, 
    handler=handler@entry=0x7fb574662ac0 <c_handler>, handler_data=handler_data@entry=0x7fb5719cfe60, 
    pre_unwind_handler=pre_unwind_handler@entry=0x7fb574662920 <pre_unwind_handler>, pre_unwind_handler_data=0xdd3bc0) at continuations.c:367
#20 0x00007fb574662eb5 in scm_c_with_continuation_barrier (func=<optimized out>, data=<optimized out>) at continuations.c:463
#21 0x00007fb5746d248c in with_guile_and_parent (base=0x7fb5719cfec0, data=0x7fb5719cfef0) at threads.c:786
#22 0x00007fb5738cb6ca in GC_call_with_stack_base (fn=0x0, fn@entry=0x7fb5746d2440 <with_guile_and_parent>, arg=0x0, arg@entry=0x7fb5719cfef0) at misc.c:1553
#23 0x00007fb5746d1c1c in scm_i_with_guile_and_parent (parent=<optimized out>, data=0x7fffcf4c8c80, func=0x7fb5746d2cc0 <really_spawn>) at threads.c:829
#24 spawn_thread (d=0x7fffcf4c8c80) at threads.c:963
#25 0x00007fb573ed10a4 in start_thread (arg=0x7fb5719d0700) at pthread_create.c:309
#26 0x00007fb573c0662d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb)