Actions
Bug #18120
closedDeadlock and segfault when using autoload in Ractor
Description
The following scripts with autoload causes Ractor to report a deadlock and segfault (tested on Ubuntu 20.04 and macOS 11.5.2):
# test.rb
module Foo
autoload :Bar, "#{File.dirname(__FILE__)}/test2"
def self.run
workers = (0...32).map do
Ractor.new do
loop do
Bar.new
Ractor.yield nil
end
end
end
100.times { Ractor.select(*workers) }
end
end
Foo.run
# test2.rb
module Foo
class Bar
end
end
Deadlock error:
test.rb:8:in `block (3 levels) in run': No live threads left. Deadlock? (fatal)
1 threads, 1 sleeps current:0x00007fc484f3f580 main thread:0x00007fc484f3f580
* #<Thread:0x00007fc48692ee18 sleep_forever>
rb_thread_t:0x00007fc484f3f580 native:0x0000700009d00000 int:0
from test.rb:7:in `loop'
from test.rb:7:in `block (2 levels) in run'
Segfault:
test.rb:8: [BUG] Segmentation fault at 0x0000000000000005
ruby 3.1.0dev (2021-08-19T08:44:48Z master 6963f8f743) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0004 p:0007 s:0015 e:000012 BLOCK test.rb:8 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC :loop
c:0002 p:0004 s:0006 e:000005 BLOCK test.rb:7 [FINISH]
c:0001 p:---- s:0003 e:000002 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
test.rb:7:in `block (2 levels) in run'
test.rb:7:in `loop'
test.rb:8:in `block (3 levels) in run'
-- Machine register context ------------------------------------------------
RIP: 0x00005588aa4bae91 RBP: 0x00007ff6c71b7498 RSP: 0x00007ff6c79bb280
RAX: 0x00007ff6c71b73f0 RBX: 0x00007ff6c79bb3f0 RCX: 0x0000000000000005
RDX: 0x00007ff6c71b74b0 RDI: 0x0000000000000078 RSI: 0x00007ff6c71b7408
R8: 0x00005588abe843c0 R9: 0x0000000000000008 R10: 0x00007ff6b0001030
R11: 0x00007ff6b0000080 R12: 0x0000000000000006 R13: 0x00007ff6c80dbe40
R14: 0x0000000000000000 R15: 0x00007ff6c7abbb10 EFL: 0x0000000000010206
-- C level backtrace information -------------------------------------------
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_print_backtrace+0x11) [0x5588aa4f4e68] ../vm_dump.c:759
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vm_bugreport) ../vm_dump.c:1041
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_bug_for_fatal_signal+0xf6) [0x5588aa2e90e6] ../error.c:818
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(sigsegv+0x4d) [0x5588aa44aced] ../signal.c:961
/lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x7ff6cc0553c0]
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(list_del_+0x0) [0x5588aa4bae91] ../ccan/list/list.h:103
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(list_del_init_) ../ccan/list/list.h:298
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(autoload_reset) ../variable.c:2417
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_ensure+0x167) [0x5588aa2f3c97] ../eval.c:1166
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_autoload_load+0x22a) [0x5588aa4c068a] ../variable.c:2507
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_get_ev_const+0x5e) [0x5588aa4e698d] ../vm_insnhelper.c:996
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_get_ev_const) ../vm_insnhelper.c:960
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_exec_core) ../insns.def:269
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vm_exec+0x197) [0x5588aa4d7ff7] ../vm.c:2164
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(invoke_block_from_c_bh+0x130) [0x5588aa4db88a] ../vm.c:1264
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_yield) ../vm.c:1399
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_yield_0) ../vm_eval.c:1350
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(loop_i) ../vm_eval.c:1449
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vrescue2+0x114) [0x5588aa2f36c4] ../eval.c:1023
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_rescue2+0x8e) [0x5588aa2f393e] ../eval.c:1000
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_cfp_consistent_p+0x0) [0x5588aa4cc6ec] ../vm_insnhelper.c:2989
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_call_cfunc_with_frame) ../vm_insnhelper.c:2991
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_sendish+0x303) [0x5588aa4d73c3] ../vm_insnhelper.c:4562
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(vm_exec_core+0x130) [0x5588aa4e2200] ../insns.def:756
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_vm_exec+0x197) [0x5588aa4d7ff7] ../vm.c:2164
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(thread_do_start_proc+0x294) [0x5588aa48ff54] ../thread.c:716
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(thread_do_start+0xc) [0x5588aa49272c] ../thread.c:760
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(thread_start_func_2) ../thread.c:835
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(rb_native_cond_initialize+0x0) [0x5588aa492a39] ../thread_pthread.c:1051
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(register_cached_thread_and_wait) ../thread_pthread.c:1103
/home/spin/src/github.com/Shopify/ruby-master/install/bin/ruby(thread_start_func_1) ../thread_pthread.c:1058
/lib/x86_64-linux-gnu/libpthread.so.0(0x9609) [0x7ff6cc049609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7ff6cbdd3293]
Updated by ko1 (Koichi Sasada) almost 3 years ago
- Status changed from Open to Assigned
- Assignee set to ko1 (Koichi Sasada)
Updated by ko1 (Koichi Sasada) almost 3 years ago
- Status changed from Assigned to Closed
Applied in changeset git|397a509b6d0d1470df8c290d7c4adef78f1532ee.
prohibit load by autoload
on non-main Ractor
fix [Bug #18120]
Updated by wanabe (_ wanabe) over 2 years ago
- Has duplicate Bug #17489: Ractor segfaults added
Actions
Like0
Like0Like0Like0