Project

General

Profile

Bug #18329

Updated by lewispb (Lewis Buckley) over 2 years ago

The following code runs on Ruby 2.7.4 and doesn't produce a core dump. On Ruby 3.0.0, 3.0.2 and 3.1.0-preview 1 the following code produces a core dump: 

 ``` ruby 
 # example2.rb 

 module Probes 
   def self.included(base) 
     base.extend(ClassMethods) 
   end 

   module ClassMethods 
     def probe(*methods) 
       prepend(probing_module(methods)) 
     end 

     def probing_module(methods) 
       Module.new do 
         methods.each do |method| 
           define_method(method) do |*args, **kwargs, &block| 
             super(*args, **kwargs, &block) 
           end 
         end 
       end 
     end 
   end 
 end 

 class Probed 
   include Probes 

   probe :danger!, :missing 

   def danger! 
     raise "BOOM" 
   end 
 end 

 5.times do 
   subject = Probed.new 
   subject.danger! rescue RuntimeError 
   subject.missing rescue NoMethodError 
 end 
 ``` 

 ``` 
 example2.rb:15: [BUG] Segmentation fault at 0x0000000000000000 
 ruby 3.1.0preview1 (2021-11-09 master 5a3b2e6141) [x86_64-linux] 

 -- Control frame information ----------------------------------------------- 
 c:0005 p:0021 s:0022 e:000019 BLOCK    example2.rb:15 [FINISH] 
 c:0004 p:0018 s:0014 e:000013 BLOCK    example2.rb:35 [FINISH] 
 c:0003 p:---- s:0010 e:000009 CFUNC    :times 
 c:0002 p:0021 s:0006 e:000005 EVAL     example2.rb:33 [FINISH] 
 c:0001 p:0000 s:0003 E:0008e0 (none) [FINISH] 

 -- Ruby level backtrace information ---------------------------------------- 
 example2.rb:33:in `<main>' 
 example2.rb:33:in `times' 
 example2.rb:35:in `block in <main>' 
 example2.rb:15:in `block (3 levels) in probing_module' 

 -- Machine register context ------------------------------------------------ 
  RIP: 0x00007fbf3622c7e0 RBP: 0x00007fbf3537ae40 RSP: 0x00007ffc825f7570 
  RAX: 0x0000000000000000 RBX: 0x00007fbf33f9c330 RCX: 0x0000d88f02870002 
  RDX: 0x00007fbf3560e568 RDI: 0x00007fbf33fcab50 RSI: 0x0000000002870000 
   R8: 0x0000000000000000    R9: 0x00007fbf3537b000 R10: 0x00007fbf33f9c330 
  R11: 0x00007fbf3537ae40 R12: 0x00007fbf3560d1e0 R13: 0x000000000000d88f 
  R14: 0x00007fbf3560e220 R15: 0x00007fbf3560e1f8 EFL: 0x0000000000010246 

 -- C level backtrace information ------------------------------------------- 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(rb_print_backtrace+0x11) [0x7fbf3624f7ca] vm_dump.c:759 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(rb_vm_bugreport) vm_dump.c:1045 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(rb_bug_for_fatal_signal+0xf4) [0x7fbf360546b4] error.c:820 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(sigsegv+0x4d) [0x7fbf361a5b7d] signal.c:964 
 /lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x7fbf35f453c0] ../sysdeps/pthread/funlockfile.c:28 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_search_method_fastpath+0x0) [0x7fbf3622c7e0] vm_insnhelper.c:1939 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_search_super_method) vm_insnhelper.c:3785 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_sendish+0x25) [0x7fbf36237286] vm_insnhelper.c:4654 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_exec_core) insns.def:864 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(rb_vm_exec+0xe7) [0x7fbf3623af07] vm.c:2196 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(invoke_bmethod+0x15a) [0x7fbf3623bb5a] vm.c:1328 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_call_bmethod+0x116) [0x7fbf3623c326] vm_insnhelper.c:3090 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_sendish+0x3) [0x7fbf36235475] vm_insnhelper.c:4651 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_exec_core) insns.def:777 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(rb_vm_exec+0xe7) [0x7fbf3623af07] vm.c:2196 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(rb_yield_1+0x2e7) [0x7fbf3623f007] vm.c:1298 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(int_dotimes+0x5c) [0x7fbf360fb7ec] numeric.c:5213 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_call_cfunc_with_frame+0x12b) [0x7fbf3622743b] vm_insnhelper.c:3025 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_call_method_each_type+0x79) [0x7fbf3623c419] vm_insnhelper.c:3541 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_call_method+0xb4) [0x7fbf3623cdd4] vm_insnhelper.c:3665 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_sendish+0x13d) [0x7fbf3622c0bd] vm_insnhelper.c:4651 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(vm_exec_core+0x22a) [0x7fbf3623552a] insns.def:758 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(rb_vm_exec+0xe7) [0x7fbf3623af07] vm.c:2196 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(rb_ec_exec_node+0xbb) [0x7fbf360591eb] eval.c:280 
 /home/lewis/.rbenv/versions/3.1.0-preview1/lib/libruby.so.3.1(ruby_run_node+0x5a) [0x7fbf3605f41a] eval.c:321 
 /home/lewis/.rbenv/versions/3.1.0-preview1/bin/ruby(main+0x73) [0x55bfb7ca71d3] ./main.c:47 
 ... 
 ``` 

 Possibly related backtrace from our application code 

 ``` 
 -- C level backtrace information ------------------------------------------- 
 /usr/local/lib/libruby.so.3.0(rb_print_backtrace+0x11) [0x7f10a8a4d2e3] vm_dump.c:758 
 /usr/local/lib/libruby.so.3.0(rb_vm_bugreport) vm_dump.c:998 
 /usr/local/lib/libruby.so.3.0(rb_bug_for_fatal_signal+0xf4) [0x7f10a8857084] error.c:786 
 /usr/local/lib/libruby.so.3.0(sigsegv+0x4d) [0x7f10a89a41bd] signal.c:960 
 /lib/x86_64-linux-gnu/libc.so.6(0x7f10a85cf210) [0x7f10a85cf210] 
 /usr/local/lib/libruby.so.3.0(vm_cc_invalidated_p+0x4) [0x7f10a88afde4] vm_callinfo.h:363 
 /usr/local/lib/libruby.so.3.0(rb_iseq_mark) iseq.c:362 
 /usr/local/lib/libruby.so.3.0(gc_mark_imemo+0x8) [0x7f10a887e4d0] gc.c:6224 
 /usr/local/lib/libruby.so.3.0(gc_mark_children) gc.c:6290 
 /usr/local/lib/libruby.so.3.0(rgengc_rememberset_mark+0x18e) [0x7f10a8880506] gc.c:7664 
 /usr/local/lib/libruby.so.3.0(gc_marks_start) gc.c:7224 
 /usr/local/lib/libruby.so.3.0(gc_marks) gc.c:7502 
 /usr/local/lib/libruby.so.3.0(gc_start) gc.c:8322 
 /usr/local/lib/libruby.so.3.0(heap_prepare+0x2b) [0x7f10a888308b] gc.c:2049 
 /usr/local/lib/libruby.so.3.0(heap_next_freepage) gc.c:2200 
 /usr/local/lib/libruby.so.3.0(ractor_cache_slots) gc.c:2219 
 /usr/local/lib/libruby.so.3.0(newobj_slowpath) gc.c:2265 
 /usr/local/lib/libruby.so.3.0(newobj_slowpath_wb_protected) gc.c:2284 
 /usr/local/lib/libruby.so.3.0(newobj_of0+0xe) [0x7f10a888333e] gc.c:2323 
 /usr/local/lib/libruby.so.3.0(newobj_of) gc.c:2333 
 /usr/local/lib/libruby.so.3.0(rb_wb_protected_newobj_of) gc.c:2355 
 /usr/local/lib/libruby.so.3.0(str_replace_shared+0x0) [0x7f10a89c2040] string.c:773 
 /usr/local/lib/libruby.so.3.0(str_new_shared) string.c:1238 
 /usr/local/lib/libruby.so.3.0(rb_str_new_shared) string.c:1244 
 /usr/local/lib/libruby.so.3.0(rb_str_subseq+0x13f) [0x7f10a89cbd7f] string.c:2606 
 /usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame+0x11b) [0x7f10a8a2519b] vm_insnhelper.c:2926 
 /usr/local/lib/libruby.so.3.0(vm_sendish+0xe) [0x7f10a8a32277] vm_insnhelper.c:4527 
 /usr/local/lib/libruby.so.3.0(vm_exec_core) insns.def:789 
 /usr/local/lib/libruby.so.3.0(rb_vm_exec+0x19b) [0x7f10a8a37e6b] vm.c:2163 
 /usr/local/lib/libruby.so.3.0(rb_yield+0x25e) [0x7f10a8a3bd9e] vm.c:1263 
 /usr/local/lib/libruby.so.3.0(rb_ary_collect+0x5c) [0x7f10a87c888c] array.c:3635 
 /usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame+0x11b) [0x7f10a8a2519b] vm_insnhelper.c:2926 
 /usr/local/lib/libruby.so.3.0(vm_sendish+0x133) [0x7f10a8a28fa3] vm_insnhelper.c:4527 
 /usr/local/lib/libruby.so.3.0(vm_exec_core+0x1ef) [0x7f10a8a322ef] insns.def:770 
 /usr/local/lib/libruby.so.3.0(rb_vm_exec+0x19b) [0x7f10a8a37e6b] vm.c:2163 
 /usr/local/lib/libruby.so.3.0(each_with_index_i+0x77) [0x7f10a88487a7] enum.c:2400 
 /usr/local/lib/libruby.so.3.0(rb_vm_pop_frame+0x0) [0x7f10a8a2e38a] vm_insnhelper.c:3732 
 /usr/local/lib/libruby.so.3.0(vm_yield_with_cfunc) vm_insnhelper.c:3733 
 /usr/local/lib/libruby.so.3.0(invoke_block_from_c_bh+0x24) [0x7f10a8a3beab] vm.c:1358 
 /usr/local/lib/libruby.so.3.0(vm_yield) vm.c:1398 
 /usr/local/lib/libruby.so.3.0(rb_yield_0) vm_eval.c:1331 
 /usr/local/lib/libruby.so.3.0(rb_yield) vm_eval.c:1347 
 /usr/local/lib/libruby.so.3.0(RB_FL_TEST_RAW+0x0) [0x7f10a87c1e4c] array.c:2523 
 /usr/local/lib/libruby.so.3.0(RB_FL_ANY_RAW) ./include/ruby/internal/fl_type.h:258 
 /usr/local/lib/libruby.so.3.0(rb_array_len) ./include/ruby/internal/core/rarray.h:135 
 ... 
 ``` 

Back