Project

General

Profile

Actions

Feature #17638

open

Support backtracing with the libbacktrace library

Added by xtkoba (Tee KOBAYASHI) almost 4 years ago. Updated almost 4 years ago.

Status:
Assigned
Target version:
-
[ruby-core:102560]

Description

It seems that Ruby's current addr2line.c has trouble with the DWARF 5 debugging format (Bug #17585).

I propose that there be an option to use the libbacktrace library instead of addr2line.c.

A patch is attached for that. When using libbacktrace, the C level backtrace information looks as follows:

-- C level backtrace information -------------------------------------------
0x7f0cc2b3b372 rb_vm_bugreport
	/var/tmp/ruby.build/ruby-devel-x86_64/vm_dump.c:1047
0x7f0cc291e188 rb_bug_for_fatal_signal
	/var/tmp/ruby.build/ruby-devel-x86_64/error.c:801
0x7f0cc2a8a137 sigsegv
	/var/tmp/ruby.build/ruby-devel-x86_64/signal.c:960
0x7f0cc281a9bf ???
	???:0
0x7f0cc247ddf7 ???
	???:0
0x7f0cc2a8990d rb_f_kill
	/var/tmp/ruby.build/ruby-devel-x86_64/signal.c:481
0x7f0cc2a2e684 proc_rb_f_kill
	/var/tmp/ruby.build/ruby-devel-x86_64/process.c:8604
0x7f0cc2b0f2a4 ractor_safe_call_cfunc_m1
	/var/tmp/ruby.build/ruby-devel-x86_64/vm_insnhelper.c:2734
0x7f0cc2b0fecb vm_call_cfunc_with_frame
	/var/tmp/ruby.build/ruby-devel-x86_64/vm_insnhelper.c:2924
0x7f0cc2b10088 vm_call_cfunc
	/var/tmp/ruby.build/ruby-devel-x86_64/vm_insnhelper.c:2945
0x7f0cc2b11b3b vm_call_method_each_type
	/var/tmp/ruby.build/ruby-devel-x86_64/vm_insnhelper.c:3414
0x7f0cc2b11fde vm_call_method
	/var/tmp/ruby.build/ruby-devel-x86_64/vm_insnhelper.c:3507
0x7f0cc2b121ca vm_call_general
	/var/tmp/ruby.build/ruby-devel-x86_64/vm_insnhelper.c:3550
0x7f0cc2b144e7 vm_sendish
	/var/tmp/ruby.build/ruby-devel-x86_64/vm_insnhelper.c:4525
0x7f0cc2b1b196 vm_exec_core
	/var/tmp/ruby.build/ruby-devel-x86_64/insns.def:789
0x7f0cc2b308f5 rb_vm_exec
	/var/tmp/ruby.build/ruby-devel-x86_64/vm.c:2162
0x7f0cc2b316e8 rb_iseq_eval_main
	/var/tmp/ruby.build/ruby-devel-x86_64/vm.c:2419
0x7f0cc292778d rb_ec_exec_node
	/var/tmp/ruby.build/ruby-devel-x86_64/eval.c:317
0x7f0cc29278d3 ruby_run_node
	/var/tmp/ruby.build/ruby-devel-x86_64/eval.c:375
0x55ad53234234 main
	./main.c:47
0x7f0cc2468e59 ???
	???:0
0x55ad532340f9 ???
	???:0
0xffffffffffffffff ???
	???:0

The source code of libbacktrace is available from: https://github.com/ianlancetaylor/libbacktrace


Files

ruby-libbacktrace.patch (1.72 KB) ruby-libbacktrace.patch xtkoba (Tee KOBAYASHI), 02/17/2021 12:51 PM
ruby-libbacktrace-using-backtrace.patch (2.05 KB) ruby-libbacktrace-using-backtrace.patch xtkoba (Tee KOBAYASHI), 02/27/2021 10:44 PM
ruby-cygwin-backtrace.patch (1.24 KB) ruby-cygwin-backtrace.patch xtkoba (Tee KOBAYASHI), 02/27/2021 10:48 PM

Updated by xtkoba (Tee KOBAYASHI) almost 4 years ago

The patch attached here presents an alternative way of using libbacktrace, in which the return addresses are retrieved by backtrace(3) and passed to the libbacktrace functions backtrace_syminfo and backtrace_pcinfo. This patch has to be applied after the main patch.

Updated by xtkoba (Tee KOBAYASHI) almost 4 years ago

The patch attached here is to be applied after the main patch and the patch in #note-1, and is for an experiment of backtracing on Cygwin. To make it work correctly, the use of sigaltstack(2) has to be disabled, and thus this is not for a practical use.

A sample output (with input borrowed from #17661):

-- C level backtrace information -------------------------------------------
[0x100571ebb] rb_print_backtrace+0x4d
	../vm_dump.c:803
[0x100571ff7] rb_vm_bugreport+0xdf
	../vm_dump.c:1101
[0x100451317] rb_bug_for_fatal_signal+0x83
	../error.c:801
[0x100514e6c] sigsegv+0x32
	../signal.c:960
[0x180065994] register_frame_ctor+0x7fae38a4
[0x180149b47] register_frame_ctor+0x7fbc7a57
[0x1800639aa] register_frame_ctor+0x7fae18ba
[0x7ffe8a769aec] register_frame_ctor+0x7ffd8a1e79fc
[0x7ffe8a6f4fe8] register_frame_ctor+0x7ffd8a172ef8
[0x7ffe8a768bf9] register_frame_ctor+0x7ffd8a1e6b09
[0x10047c67c] rb_io_each_byte+0x6f
	../io.c:3992
	../io.c:3983
[0x10055c83c] vm_call_cfunc_with_frame+0x12c
	../vm_insnhelper.c:2924
[0x100562585] vm_sendish+0xf2
	../vm_insnhelper.c:4525
[0x1005698ca] vm_exec_core+0x1881
	../insns.def:770
[0x100562c2e] rb_vm_exec+0x20e
	../vm.c:2171
[0x100454abe] rb_ec_exec_node+0x13b
	../eval.c:317
[0x100458c7a] ruby_run_node+0x64
	../eval.c:375
[0x100581d9c] main+0x7c
	../main.c:47
[0x18004adef] register_frame_ctor+0x7fac8cff
[0x180048825] register_frame_ctor+0x7fac6735
[0x1800488d3] register_frame_ctor+0x7fac67e3

Updated by mame (Yusuke Endoh) almost 4 years ago

  • Status changed from Open to Assigned
  • Assignee set to naruse (Yui NARUSE)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0