Project

General

Profile

Feature #18483

Updated by ko1 (Koichi Sasada) over 2 years ago

Now development version of MRI (`RUBY_DEVEL` macro enabled binary) supports `RUBY_ON_BUG` environment variable. 
 It kicks the specified process with PID of the Ruby process when `rb_bug()` function is called, like: 

 ``` 
 $ RUBY_ON_BUG='gdb -p' ./miniruby -e 'Process.kill(:SEGV, $$)' 
 -e:1: [BUG] Segmentation fault at 0x000003e800000512 
 ruby 3.2.0dev (2022-01-12T02:02:24Z master dcb02cb28a) [x86_64-linux] 

 GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2 
 Copyright (C) 2020 Free Software Foundation, Inc. 
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
 This is free software: you are free to change and redistribute it. 
 There is NO WARRANTY, to the extent permitted by law. 
 Type "show copying" and "show warranty" for details. 
 This GDB was configured as "x86_64-linux-gnu". 
 Type "show configuration" for configuration details. 
 For bug reporting instructions, please see: 
 <http://www.gnu.org/software/gdb/bugs/>. 
 Find the GDB manual and other documentation resources online at: 
     <http://www.gnu.org/software/gdb/documentation/>. 

 For help, type "help". 
 Type "apropos word" to search for commands related to "word". 
 Attaching to process 1298 
 Reading symbols from /home/ko1/ruby/build/trunk/miniruby... 
 Reading symbols from /lib/x86_64-linux-gnu/libz.so.1... 
 (No debugging symbols found in /lib/x86_64-linux-gnu/libz.so.1) 
 Reading symbols from /lib/x86_64-linux-gnu/libpthread.so.0... 
 Reading symbols from /usr/lib/debug/.build-id/e5/4761f7b554d0fcc1562959665d93dffbebdaf0.debug... 
 [Thread debugging using libthread_db enabled] 
 Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 
 Reading symbols from /lib/x86_64-linux-gnu/librt.so.1... 
 Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/librt-2.31.so... 
 Reading symbols from /lib/x86_64-linux-gnu/libgmp.so.10... 
 (No debugging symbols found in /lib/x86_64-linux-gnu/libgmp.so.10) 
 Reading symbols from /lib/x86_64-linux-gnu/libcapstone.so.3... 
 (No debugging symbols found in /lib/x86_64-linux-gnu/libcapstone.so.3) 
 Reading symbols from /lib/x86_64-linux-gnu/libdl.so.2... 
 Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libdl-2.31.so... 
 Reading symbols from /lib/x86_64-linux-gnu/libcrypt.so.1... 
 (No debugging symbols found in /lib/x86_64-linux-gnu/libcrypt.so.1) 
 Reading symbols from /lib/x86_64-linux-gnu/libm.so.6... 
 Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libm-2.31.so... 
 Reading symbols from /lib/x86_64-linux-gnu/libc.so.6... 
 Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.31.so... 
 Reading symbols from /lib64/ld-linux-x86-64.so.2... 
 (No debugging symbols found in /lib64/ld-linux-x86-64.so.2) 
 0x00007fc0a0099dba in __GI___wait4 (pid=1299, stat_loc=stat_loc@entry=0x558e2382b5d8, options=options@entry=0, usage=usage@entry=0x0) 
     at ../sysdeps/unix/sysv/linux/wait4.c:27 
 27        ../sysdeps/unix/sysv/linux/wait4.c: No such file or directory. 
 (gdb) 
 ``` 

 This feature is convenient for CI and so on. 
 Again, this feature is only enabled on `RUBY_DEVEL`. This is because I'm not sure it can be a security issue. 
 However, we discussed about this feature and we concluded it is not a problem to contain this kind of feature (if (it `RUBYOPT` is modified, it is already issue). 

 So I want to enable this feature. 

 Two points we need to discuss. 

 * anyone have security concern about this feature on release version? 
 * `RUBY_ON_BUG` is named without any discussion because it is only MRI development. However if it is enabled on release version, the name should be discussed. Any good name? 

 Thanks, 
 Koichi

Back