Project

General

Profile

Actions

Bug #18257

open

SystemTap/DTrace coredump on ppc64le/s390x

Added by vo.x (Vit Ondruch) about 2 months ago. Updated 11 days ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [powerpc64le-linux]
[ruby-core:105692]

Description

Testing Ruby with SystemTap on RHEL9 beta following these steps:

$ stap -v /usr/share/doc/ruby-doc/ruby-exercise.stp &
$ ruby -e '[1, 2, 3].push(4)'

I get the following error:

/usr/share/rubygems/rubygems/errors.rb:181: [BUG] Segmentation fault at 0x0000000000000014
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [powerpc64le-linux]

-- Control frame information -----------------------------------------------
c:0008 p:0028 s:0032 e:000027 CLASS  /usr/share/rubygems/rubygems/errors.rb:181
c:0007 p:0110 s:0025 e:000024 CLASS  /usr/share/rubygems/rubygems/errors.rb:153
c:0006 p:0007 s:0022 e:000021 TOP    /usr/share/rubygems/rubygems/errors.rb:9 [FINISH]
c:0005 p:---- s:0019 e:000018 CFUNC  :require
c:0004 p:0037 s:0014 e:000013 TOP    /usr/share/rubygems/rubygems.rb:19 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC  :require
c:0002 p:0012 s:0006 e:000005 TOP    <internal:gem_prelude>:2 [FINISH]
c:0001 p:0000 s:0003 E:0026c0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
<internal:gem_prelude>:2:in `<internal:gem_prelude>'
<internal:gem_prelude>:2:in `require'
/usr/share/rubygems/rubygems.rb:19:in `<top (required)>'
/usr/share/rubygems/rubygems.rb:19:in `require'
/usr/share/rubygems/rubygems/errors.rb:9:in `<top (required)>'
/usr/share/rubygems/rubygems/errors.rb:153:in `<module:Gem>'
/usr/share/rubygems/rubygems/errors.rb:181:in `<class:SourceFetchProblem>'

-- C level backtrace information -------------------------------------------
/lib64/libruby.so.3.0(0x7fffb3b06ba0) [0x7fffb3b06ba0]
/lib64/libruby.so.3.0(0x7fffb38d9680) [0x7fffb38d9680]
/lib64/libruby.so.3.0(0x7fffb3a4b9d8) [0x7fffb3a4b9d8]
linux-vdso64.so.1(__kernel_sigtramp_rt64+0x0) [0x7fffb3ca0464]
[0x7fffb3a67ff8]
/lib64/libruby.so.3.0(rb_str_dup+0x130) [0x7fffb3a6b950]
/lib64/libruby.so.3.0(rb_class_path+0x3c) [0x7fffb3ac72ac]
/lib64/libruby.so.3.0(rb_dtrace_setup+0x134) [0x7fffb3ae46a4]
[0x7fffb3ae4a00]
[0x7fffb3ae7644]
[0x7fffb3aeba5c]
/lib64/libruby.so.3.0(rb_vm_exec+0x140) [0x7fffb3af1710]
/lib64/libruby.so.3.0(rb_iseq_eval+0x164) [0x7fffb3af29f4]
[0x7fffb394ce68]
/lib64/libruby.so.3.0(rb_require_string+0x44) [0x7fffb394e7f4]
/lib64/libruby.so.3.0(rb_f_require+0x1c) [0x7fffb394e88c]
[0x7fffb3acf538]
[0x7fffb3ae4900]
[0x7fffb3ae7644]
[0x7fffb3aeba5c]
/lib64/libruby.so.3.0(rb_vm_exec+0x140) [0x7fffb3af1710]
/lib64/libruby.so.3.0(rb_iseq_eval+0x164) [0x7fffb3af29f4]
[0x7fffb394ce68]
/lib64/libruby.so.3.0(rb_require_string+0x44) [0x7fffb394e7f4]
/lib64/libruby.so.3.0(rb_f_require+0x1c) [0x7fffb394e88c]
[0x7fffb3acf538]
[0x7fffb3ae4900]
[0x7fffb3ae7644]
[0x7fffb3aeba5c]
/lib64/libruby.so.3.0(rb_vm_exec+0x140) [0x7fffb3af1710]
/lib64/libruby.so.3.0(rb_iseq_eval+0x164) [0x7fffb3af29f4]
[0x7fffb3b15f60]
[0x7fffb3a4826c]
[0x7fffb3a499d8]
/lib64/libruby.so.3.0(ruby_process_options+0x158) [0x7fffb3a4a778]
/lib64/libruby.so.3.0(ruby_options+0xf4) [0x7fffb38e5904]
[0x11a360a60]
[0x7fffb35d7ca4]
[0x7fffb35d7e80]

-- Other runtime information -----------------------------------------------

* Loaded script: ruby

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 ruby2_keywords.rb
    5 /usr/lib64/ruby/enc/encdb.so
    6 /usr/lib64/ruby/enc/trans/transdb.so
    7 /usr/lib64/ruby/rbconfig.rb
    8 /usr/share/rubygems/rubygems/compatibility.rb
    9 /usr/share/rubygems/rubygems/defaults.rb
   10 /usr/share/rubygems/rubygems/deprecate.rb

* Process memory map:

11a360000-11a370000 r-xp 00000000 fd:00 34097694                         /usr/bin/ruby
11a370000-11a380000 r--p 00000000 fd:00 34097694                         /usr/bin/ruby
11a380000-11a390000 rw-p 00010000 fd:00 34097694                         /usr/bin/ruby
1000d490000-1000d6b0000 rw-p 00000000 00:00 0                            [heap]
7fffaf470000-7fffaf8d0000 r--s 00000000 fd:00 67811909                   /usr/lib64/libruby.so.3.0.2
7fffaf8d0000-7fffaf8f0000 r--s 00000000 fd:00 34097694                   /usr/bin/ruby
7fffaf8f0000-7fffaf900000 r-xp 00000000 fd:00 100999014                  /usr/lib64/ruby/enc/trans/transdb.so
7fffaf900000-7fffaf910000 r--p 00000000 fd:00 100999014                  /usr/lib64/ruby/enc/trans/transdb.so
7fffaf910000-7fffaf920000 rw-p 00000000 00:00 0 
7fffaf920000-7fffaf930000 r-xp 00000000 fd:00 67811915                   /usr/lib64/ruby/enc/encdb.so
7fffaf930000-7fffaf940000 r--p 00000000 fd:00 67811915                   /usr/lib64/ruby/enc/encdb.so
7fffaf940000-7fffaf950000 rw-p 00000000 00:00 0 
7fffaf950000-7fffaf960000 ---p 00000000 00:00 0 
7fffaf960000-7fffafa10000 rw-p 00000000 00:00 0 
7fffafa10000-7fffafa20000 ---p 00000000 00:00 0 
7fffafa20000-7fffafad0000 rw-p 00000000 00:00 0 
7fffafad0000-7fffafae0000 ---p 00000000 00:00 0 
7fffafae0000-7fffafb90000 rw-p 00000000 00:00 0 
7fffafb90000-7fffafba0000 ---p 00000000 00:00 0 
7fffafba0000-7fffafc50000 rw-p 00000000 00:00 0 
7fffafc50000-7fffafc60000 ---p 00000000 00:00 0 
7fffafc60000-7fffafd10000 rw-p 00000000 00:00 0 
7fffafd10000-7fffafd20000 ---p 00000000 00:00 0 
7fffafd20000-7fffafdd0000 rw-p 00000000 00:00 0 
7fffafdd0000-7fffafde0000 ---p 00000000 00:00 0 
7fffafde0000-7fffafe90000 rw-p 00000000 00:00 0 
7fffafe90000-7fffafea0000 ---p 00000000 00:00 0 
7fffafea0000-7fffaff50000 rw-p 00000000 00:00 0 
7fffaff50000-7fffaff60000 ---p 00000000 00:00 0 
7fffaff60000-7fffb0010000 rw-p 00000000 00:00 0 
7fffb0010000-7fffb0020000 ---p 00000000 00:00 0 
7fffb0020000-7fffb00d0000 rw-p 00000000 00:00 0 
7fffb00d0000-7fffb00e0000 ---p 00000000 00:00 0 
7fffb00e0000-7fffb0190000 rw-p 00000000 00:00 0 
7fffb0190000-7fffb01a0000 ---p 00000000 00:00 0 
7fffb01a0000-7fffb0250000 rw-p 00000000 00:00 0 
7fffb0250000-7fffb0260000 ---p 00000000 00:00 0 
7fffb0260000-7fffb0310000 rw-p 00000000 00:00 0 
7fffb0310000-7fffb0320000 ---p 00000000 00:00 0 
7fffb0320000-7fffb03d0000 rw-p 00000000 00:00 0 
7fffb03d0000-7fffb03e0000 ---p 00000000 00:00 0 
7fffb03e0000-7fffb0490000 rw-p 00000000 00:00 0 
7fffb0490000-7fffb04a0000 ---p 00000000 00:00 0 
7fffb04a0000-7fffb0550000 rw-p 00000000 00:00 0 
7fffb0550000-7fffb0560000 ---p 00000000 00:00 0 
7fffb0560000-7fffb0610000 rw-p 00000000 00:00 0 
7fffb0610000-7fffb0620000 ---p 00000000 00:00 0 
7fffb0620000-7fffb06d0000 rw-p 00000000 00:00 0 
7fffb06d0000-7fffb06e0000 ---p 00000000 00:00 0 
7fffb06e0000-7fffb0790000 rw-p 00000000 00:00 0 
7fffb0790000-7fffb07a0000 ---p 00000000 00:00 0 
7fffb07a0000-7fffb0850000 rw-p 00000000 00:00 0 
7fffb0850000-7fffb0860000 ---p 00000000 00:00 0 
7fffb0860000-7fffb0910000 rw-p 00000000 00:00 0 
7fffb0910000-7fffb0920000 ---p 00000000 00:00 0 
7fffb0920000-7fffb09d0000 rw-p 00000000 00:00 0 
7fffb09d0000-7fffb09e0000 ---p 00000000 00:00 0 
7fffb09e0000-7fffb0a90000 rw-p 00000000 00:00 0 
7fffb0a90000-7fffb0aa0000 ---p 00000000 00:00 0 
7fffb0aa0000-7fffb0b50000 rw-p 00000000 00:00 0 
7fffb0b50000-7fffb0b60000 ---p 00000000 00:00 0 
7fffb0b60000-7fffb0c10000 rw-p 00000000 00:00 0 
7fffb0c10000-7fffb0c20000 ---p 00000000 00:00 0 
7fffb0c20000-7fffb0cd0000 rw-p 00000000 00:00 0 
7fffb0cd0000-7fffb0ce0000 ---p 00000000 00:00 0 
7fffb0ce0000-7fffb0d90000 rw-p 00000000 00:00 0 
7fffb0d90000-7fffb0da0000 ---p 00000000 00:00 0 
7fffb0da0000-7fffb0e50000 rw-p 00000000 00:00 0 
7fffb0e50000-7fffb0e60000 ---p 00000000 00:00 0 
7fffb0e60000-7fffb0f10000 rw-p 00000000 00:00 0 
7fffb0f10000-7fffb0f20000 ---p 00000000 00:00 0 
7fffb0f20000-7fffb0fd0000 rw-p 00000000 00:00 0 
7fffb0fd0000-7fffb0fe0000 ---p 00000000 00:00 0 
7fffb0fe0000-7fffb1090000 rw-p 00000000 00:00 0 
7fffb1090000-7fffb10a0000 ---p 00000000 00:00 0 
7fffb10a0000-7fffb32e0000 rw-p 00000000 00:00 0 
7fffb32e0000-7fffb3340000 r--p 00000000 fd:00 33555845                   /usr/lib/locale/en_US.utf8/LC_CTYPE
7fffb3340000-7fffb3420000 r-xp 00000000 fd:00 67172714                   /usr/lib64/libm.so.6
7fffb3420000-7fffb3430000 r--p 000d0000 fd:00 67172714                   /usr/lib64/libm.so.6
7fffb3430000-7fffb3440000 rw-p 000e0000 fd:00 67172714                   /usr/lib64/libm.so.6
7fffb3440000-7fffb3480000 r-xp 00000000 fd:00 67172871                   /usr/lib64/libcrypt.so.2.0.0
7fffb3480000-7fffb3490000 r--p 00030000 fd:00 67172871                   /usr/lib64/libcrypt.so.2.0.0
7fffb3490000-7fffb34a0000 rw-p 00000000 00:00 0 
7fffb34a0000-7fffb3540000 r-xp 00000000 fd:00 67172912                   /usr/lib64/libgmp.so.10.4.0
7fffb3540000-7fffb3550000 r--p 00090000 fd:00 67172912                   /usr/lib64/libgmp.so.10.4.0
7fffb3550000-7fffb3560000 rw-p 000a0000 fd:00 67172912                   /usr/lib64/libgmp.so.10.4.0
7fffb3560000-7fffb3580000 r-xp 00000000 fd:00 67172832                   /usr/lib64/libz.so.1.2.11
7fffb3580000-7fffb3590000 r--p 00010000 fd:00 67172832                   /usr/lib64/libz.so.1.2.11
7fffb3590000-7fffb35a0000 rw-p 00020000 fd:00 67172832                   /usr/lib64/libz.so.1.2.11
7fffb35a0000-7fffb37e0000 r-xp 00000000 fd:00 67172711                   /usr/lib64/libc.so.6
7fffb37e0000-7fffb37f0000 r--p 00230000 fd:00 67172711                   /usr/lib64/libc.so.6
7fffb37f0000-7fffb3800000 rw-p 00240000 fd:00 67172711                   /usr/lib64/libc.so.6
7fffb3800000-7fffb3c30000 r-xp 00000000 fd:00 67811909                   /usr/lib64/libruby.so.3.0.2
7fffb3c30000-7fffb3c40000 ---p 00430000 fd:00 67811909                   /usr/lib64/libruby.so.3.0.2
7fffb3c40000-7fffb3c50000 r--p 00430000 fd:00 67811909                   /usr/lib64/libruby.so.3.0.2
7fffb3c50000-7fffb3c60000 rw-p 00440000 fd:00 67811909                   /usr/lib64/libruby.so.3.0.2
7fffb3c60000-7fffb3c70000 rw-p 00000000 00:00 0 
7fffb3c70000-7fffb3c80000 r--s 00000000 fd:00 100673889                  /usr/lib64/gconv/gconv-modules.cache
7fffb3c80000-7fffb3ca0000 r--p 00000000 00:00 0                          [vvar]
7fffb3ca0000-7fffb3cb0000 r-xp 00000000 00:00 0                          [vdso]
7fffb3cb0000-7fffb3d00000 r-xp 00000000 fd:00 67172707                   /usr/lib64/ld64.so.2
7fffb3d00000-7fffb3d10000 r--p 00040000 fd:00 67172707                   /usr/lib64/ld64.so.2
7fffb3d10000-7fffb3d20000 rw-p 00050000 fd:00 67172707                   /usr/lib64/ld64.so.2
7fffdee00000-7fffdf600000 rw-p 00000000 00:00 0                          [stack]

This should be the full BT:

(gdb) bt
#0  0x00007fffa5711550 in uleb128 (p=0x10039917f10) at addr2line.c:200
#1  di_read_die (reader=reader@entry=0x10039917eb8, die=die@entry=0x10039917dc8) at addr2line.c:1343
#2  0x00007fffa5714574 in debug_info_read (offset=<optimized out>, lines=<optimized out>, traces=<optimized out>, num_traces=<optimized out>, reader=<optimized out>) at addr2line.c:1630
#3  fill_lines (num_traces=num_traces@entry=39, traces=traces@entry=0x7fffa585d778 <trace>, check_debuglink=check_debuglink@entry=0, objp=objp@entry=0x10039919370, lines=lines@entry=0x100399756f0, 
    offset=<optimized out>, offset@entry=0) at addr2line.c:1887
#4  0x00007fffa5714f28 in follow_debuglink (offset=0, lines=0x100399756f0, objp=0x10039919370, traces=<optimized out>, num_traces=39, debuglink=0x7fffa14e01e4 "ruby-3.0.2-155.el9.ppc64le.debug")
    at addr2line.c:574
#5  fill_lines (num_traces=num_traces@entry=39, traces=traces@entry=0x7fffa585d778 <trace>, check_debuglink=check_debuglink@entry=1, objp=0x10039919370, objp@entry=0x100399193f0, 
    lines=lines@entry=0x100399756f0, offset=<optimized out>, offset@entry=-1) at addr2line.c:1925
#6  0x00007fffa571576c in rb_dump_backtrace_with_lines (num_traces=<optimized out>, traces=0x7fffa585d778 <trace>) at addr2line.c:2286
#7  0x00007fffa5706bac in rb_print_backtrace () at vm_dump.c:760
#8  rb_vm_bugreport (ctx=<optimized out>) at vm_dump.c:998
#9  0x00007fffa54d9680 in rb_bug_for_fatal_signal (default_sighandler=0x0, sig=<optimized out>, ctx=0x100399197c0, fmt=0x7fffa574e8f0 "Segmentation fault at %p") at error.c:786
#10 0x00007fffa564b9d8 in sigsegv (sig=<optimized out>, info=0x1003991a540, ctx=0x100399197c0) at signal.c:960
#11 <signal handler called>
#12 0x00007fffa5667ff8 in str_new_frozen_buffer (klass=klass@entry=1100477014720, orig=orig@entry=1100476844400, copy_encoding=copy_encoding@entry=1) at string.c:1329
#13 0x00007fffa566b950 in str_new_frozen (orig=1100476844400, klass=1100477014720) at string.c:1297
#14 str_duplicate_setup (dup=1100478149120, str=1100476844400, klass=1100477014720) at string.c:1570
#15 str_duplicate (str=1100476844400, klass=1100477014720) at string.c:1602
#16 rb_str_dup (str=1100476844400) at string.c:1608
#17 0x00007fffa56c72ac in rb_class_path (klass=1100476844480) at variable.c:173
#18 0x00007fffa56e46a4 in rb_dtrace_setup (ec=<optimized out>, klass=1100476844480, id=159, args=0x7fffe9d953d8) at vm.c:449
#19 0x00007fffa56e4a00 in vm_call_cfunc_with_frame (ec=<optimized out>, reg_cfp=0x7fffa4ecfe50, calling=<optimized out>) at vm_insnhelper.c:2916
#20 0x00007fffa56e7644 in vm_sendish (ec=0x10039811cf0, reg_cfp=0x7fffa4ecfe50, cd=0x100399a8db0, block_handler=<optimized out>, method_explorer=<optimized out>) at vm_callinfo.h:336
#21 0x00007fffa56eba5c in vm_exec_core (ec=0x10039811cf0, initial=<optimized out>, initial@entry=0) at insns.def:789
#22 0x00007fffa56f1710 in rb_vm_exec (ec=0x10039811cf0, mjit_enable_p=<optimized out>) at vm.c:2172
#23 0x00007fffa56f29f4 in rb_iseq_eval (iseq=0x100398aa7c0) at vm.c:2409
#24 0x00007fffa554ce68 in load_iseq_eval (fname=1100477137480, ec=0x10039811cf0) at load.c:594
#25 require_internal (ec=ec@entry=0x10039811cf0, fname=<optimized out>, fname@entry=1100476430040, exception=exception@entry=1) at load.c:1065
#26 0x00007fffa554e7f4 in rb_require_string (fname=1100476430040) at load.c:1142
#27 0x00007fffa554e88c in rb_f_require (obj=<optimized out>, fname=<optimized out>) at load.c:838
#28 0x00007fffa56cf538 in ractor_safe_call_cfunc_1 (recv=<optimized out>, argc=<optimized out>, argv=<optimized out>, func=<optimized out>) at vm_insnhelper.c:2750
#29 0x00007fffa56e4900 in vm_call_cfunc_with_frame (ec=0x10039811cf0, reg_cfp=0x7fffa4ecff30, calling=<optimized out>) at vm_insnhelper.c:2926
#30 0x00007fffa56e7644 in vm_sendish (ec=0x10039811cf0, reg_cfp=0x7fffa4ecff30, cd=0x10039901e50, block_handler=<optimized out>, method_explorer=<optimized out>) at vm_callinfo.h:336
#31 0x00007fffa56eba5c in vm_exec_core (ec=0x10039811cf0, initial=<optimized out>, initial@entry=0) at insns.def:789
#32 0x00007fffa56f1710 in rb_vm_exec (ec=0x10039811cf0, mjit_enable_p=<optimized out>) at vm.c:2172
#33 0x00007fffa56f29f4 in rb_iseq_eval (iseq=0x1003981b9a8) at vm.c:2409
#34 0x00007fffa554ce68 in load_iseq_eval (fname=1100476613760, ec=0x10039811cf0) at load.c:594
#35 require_internal (ec=ec@entry=0x10039811cf0, fname=<optimized out>, fname@entry=1100476614040, exception=exception@entry=1) at load.c:1065
#36 0x00007fffa554e7f4 in rb_require_string (fname=1100476614040) at load.c:1142
#37 0x00007fffa554e88c in rb_f_require (obj=<optimized out>, fname=<optimized out>) at load.c:838
#38 0x00007fffa56cf538 in ractor_safe_call_cfunc_1 (recv=<optimized out>, argc=<optimized out>, argv=<optimized out>, func=<optimized out>) at vm_insnhelper.c:2750
#39 0x00007fffa56e4900 in vm_call_cfunc_with_frame (ec=0x10039811cf0, reg_cfp=0x7fffa4ecffa0, calling=<optimized out>) at vm_insnhelper.c:2926
#40 0x00007fffa56e7644 in vm_sendish (ec=0x10039811cf0, reg_cfp=0x7fffa4ecffa0, cd=0x10039970580, block_handler=<optimized out>, method_explorer=<optimized out>) at vm_callinfo.h:336
#41 0x00007fffa56eba5c in vm_exec_core (ec=0x10039811cf0, initial=<optimized out>, initial@entry=0) at insns.def:789
#42 0x00007fffa56f1710 in rb_vm_exec (ec=0x10039811cf0, mjit_enable_p=<optimized out>) at vm.c:2172
#43 0x00007fffa56f29f4 in rb_iseq_eval (iseq=0x100398489f8) at vm.c:2409
#44 0x00007fffa5715f60 in rb_load_with_builtin_functions (feature_name=0x7fffa57b61c0 "gem_prelude", table=0x0) at builtin.c:54
#45 0x00007fffa564826c in ruby_init_prelude () at ruby.c:1498
#46 ruby_opt_init (opt=0x7fffe9d98690) at ruby.c:1521
#47 ruby_opt_init (opt=0x7fffe9d98690) at ruby.c:1506
#48 0x00007fffa56499d8 in process_options (argc=0, argc@entry=3, argv=0x7fffe9d98f10, argv@entry=0x7fffe9d98ef8, opt=opt@entry=0x7fffe9d98690) at ruby.c:1951
#49 0x00007fffa564a778 in ruby_process_options (argc=<optimized out>, argv=0x7fffe9d98ef8) at ruby.c:230
#50 0x00007fffa54e5904 in ruby_options (argc=<optimized out>, argv=0x7fffe9d98ef8) at eval.c:138
#51 0x000000010b860a60 in main (argc=<optimized out>, argv=<optimized out>) at ./main.c:50

Updated by vo.x (Vit Ondruch) about 2 months ago

My guess is that this is not really platform dependent, but instead, this is GC and it exhibits on different platforms just due to different memory layout. I think the issue is that the DTrace probe is trying to access some information which was previously swept by GC. This limits the issue in this simple example it seems:

$ RUBY_GC_HEAP_INIT_SLOTS=100000 ruby -e '[1, 2, 3].push(4)'

Using two ssh sessions, I have now noticed that there are also quite some messages such as the following reported:

RSTRING_PTR is returning NULL!! SIGSEGV is highly expected to follow immediately. If you could reproduce, attach your debugger here, and look at the passed string.

Updated by vo.x (Vit Ondruch) about 2 months ago

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7d47ff8 in str_new_frozen_buffer (klass=klass@entry=4295795400, orig=orig@entry=4295625080, copy_encoding=copy_encoding@entry=1) at string.c:1329
1329        else if (STR_EMBEDDABLE_P(RSTRING_LEN(orig), TERM_LEN(orig))) {
(gdb) p (*(struct RString *)(orig))
$1 = {basic = {flags = 73831, klass = 4295795400}, as = {heap = {len = 4295436520, ptr = 0x100072870 "e\bS ", aux = {capa = 0, shared = 0}}, 
    ary = "\350(\a\000\001\000\000\000p(\a\000\001\000\000\000\000\000\000\000\000\000\000"}}

Not sure this is helpful ...

Updated by nobu (Nobuyoshi Nakada) about 2 months ago

vo.x (Vit Ondruch) wrote in #note-2:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7d47ff8 in str_new_frozen_buffer (klass=klass@entry=4295795400, orig=orig@entry=4295625080, copy_encoding=copy_encoding@entry=1) at string.c:1329
1329      else if (STR_EMBEDDABLE_P(RSTRING_LEN(orig), TERM_LEN(orig))) {
(gdb) p (*(struct RString *)(orig))
$1 = {basic = {flags = 73831, klass = 4295795400}, as = {heap = {len = 4295436520, ptr = 0x100072870 "e\bS ", aux = {capa = 0, shared = 0}}, 
    ary = "\350(\a\000\001\000\000\000p(\a\000\001\000\000\000\000\000\000\000\000\000\000"}}

Not sure this is helpful ...

The flags 73831 = 0x12067, that means orig is an Array object, which has two elements(0x00000001000728e8, 0x0000000100072870).

Updated by nobu (Nobuyoshi Nakada) about 2 months ago

I think a condition of "RSTRING_PTR is returning NULL!!" was fixed this year, but can't remember now.

Updated by vo.x (Vit Ondruch) 12 days ago

nobu (Nobuyoshi Nakada) wrote in #note-3:

vo.x (Vit Ondruch) wrote in #note-2:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7d47ff8 in str_new_frozen_buffer (klass=klass@entry=4295795400, orig=orig@entry=4295625080, copy_encoding=copy_encoding@entry=1) at string.c:1329
1329        else if (STR_EMBEDDABLE_P(RSTRING_LEN(orig), TERM_LEN(orig))) {
(gdb) p (*(struct RString *)(orig))
$1 = {basic = {flags = 73831, klass = 4295795400}, as = {heap = {len = 4295436520, ptr = 0x100072870 "e\bS ", aux = {capa = 0, shared = 0}}, 
    ary = "\350(\a\000\001\000\000\000p(\a\000\001\000\000\000\000\000\000\000\000\000\000"}}

Not sure this is helpful ...

The flags 73831 = 0x12067, that means orig is an Array object, which has two elements(0x00000001000728e8, 0x0000000100072870).

If that was array, then this is the output:

(gdb) p (*(struct RArray *)(orig))
$3 = {basic = {flags = 73831, klass = 4295795400}, as = {heap = {len = 4295436520, aux = {capa = 4295436400, shared_root = 4295436400}, ptr = 0x0}, ary = {4295436520, 4295436400, 0}}}

(gdb) call ruby_debug_print_v(orig)
DBG> : 0x00000001000a0978 [3LM   ] T_ARRAY (Array)[E ] len: 2 (embed)

(gdb) call ruby_debug_print_v((*(struct RArray *)(orig))->as->ary[0])
DBG> : 0x00000001000728e8 [3LM   ] T_STRING (String)Ruby

(gdb) call ruby_debug_print_v((*(struct RArray *)(orig))->as->ary[1])
DBG> : 0x0000000100072870 [3LM   ] T_STRING (String)BSD-2-Clause

But why it should be array on such place? Isn't it the crux of the problem? Can rb_tmp_class_path 1 return array?

Just FTR, there is this RHEL8 ticket 2 and it seems there is certainly something fishy with the SystemTap/DTrace probes, because they can report some random strings.

Updated by vo.x (Vit Ondruch) 12 days ago

Interestingly, the error exhibits on two palces as far as I can tell:

https://github.com/ruby/ruby/blob/v3_0_2/lib/rubygems/errors.rb#L181
https://github.com/ruby/ruby/blob/0db68f023372b634603c74fca94588b457be084c/ext/monitor/lib/monitor.rb#L165

The error.rb corresponds with the original report, while the other place is monitor.rb. What is interesting is that both places try to setup aliases.

Updated by vo.x (Vit Ondruch) 12 days ago

So the array comes via this path:

https://github.com/ruby/ruby/blob/0db68f023372b634603c74fca94588b457be084c/variable.c#L172
https://github.com/ruby/ruby/blob/0db68f023372b634603c74fca94588b457be084c/variable.c#L148
https://github.com/ruby/ruby/blob/0db68f023372b634603c74fca94588b457be084c/variable.c#L102

And these are the variables:

(gdb) call ruby_debug_print_v(klass)
DBG> : 0x00000001000a09c8 [3LM   ] T_ICLASS

(gdb) call ruby_debug_print_v(n)
DBG> : 0x00000001000a0978 [3LM   ] T_ARRAY (Array)[E ] len: 2 (embed)

Updated by vo.x (Vit Ondruch) 11 days ago

This is the status right before the hook is called:

#0  vm_call_cfunc_with_frame (ec=0x100031cf0, reg_cfp=0x7ffff75afe18, calling=0x7fffffffa790) at vm_insnhelper.c:2916
2916        RUBY_DTRACE_CMETHOD_ENTRY_HOOK(ec, me->owner, me->def->original_id);
(gdb) call ruby_debug_print_v(me)
DBG> : 0x00000001000a0928 [3LM   ] T_IMEMO <ment> :core#set_method_alias (pub,cc) type:cfunc alias:0 owner:0x00000001000a0950 defined_class:0x00000001000a0950
(gdb) call ruby_debug_print_v(me->owner)
DBG> : 0x00000001000a0950 [3LM   ] T_CLASS (annon)

And here the klass changes:

#0  rb_dtrace_setup (ec=<optimized out>, klass=4295625040, id=159, args=0x7fffffffa678) at vm.c:444
444     klass = rb_attr_get(klass, id__attached__);
(gdb) l
439     }
440     if (RB_TYPE_P(klass, T_ICLASS)) {
441     klass = RBASIC(klass)->klass;
442     }
443     else if (FL_TEST(klass, FL_SINGLETON)) {
444     klass = rb_attr_get(klass, id__attached__);
445     if (NIL_P(klass)) return FALSE;
446     }
447     type = BUILTIN_TYPE(klass);
448     if (type == T_CLASS || type == T_ICLASS || type == T_MODULE) {
(gdb) n
445     if (NIL_P(klass)) return FALSE;
(gdb) call ruby_debug_print_v(klass)
DBG> : 0x00000001000a09c8 [3LM   ] T_ICLASS 

I am not sure I understand what the rb_attr_get(klass, id__attached__) actually does. Originally 1, there used to be used just rb_class2name which would work for this case:

(gdb) call rb_class2name(klass)
$44 = 0x1000f28f0 "BasicObject"
Actions

Also available in: Atom PDF