Bug #9295

`Exception#backtrace_locations` returns `nil`

Added by Tsuyoshi Sawada about 1 year ago. Updated about 1 year ago.

[ruby-core:59306]
Status:Closed
Priority:High
Assignee:-
ruby -v:2.1 Backport:1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: UNKNOWN

Description

=begin
If I raise an ArgumentError by calling a method with wrong number of arguments, Exception#backtrace_locations returns nil, which I think is a bug:

def foo; end

begin
  foo(:bar)
rescue => e
  p e.backtrace_locations
end
# => nil

If, instead, I raise an error manually, then it returns an array as expected:

begin
  raise ArgumentError.new
rescue => e
  p e.backtrace_locations
end
# => ["this_file:2:in `<main>'"]

=end

Associated revisions

Revision 44411
Added by Koichi Sasada about 1 year ago

  • vm_insnhelper.c (argument_error): insert dummy frame to make a backtrace object intead of modify backtrace string array. [Bug #9295]
  • test/ruby/test_backtrace.rb: add a test for this patch. fix test to compare a result of Exception#backtrace with a result of Exception#backtrace_locations.

Revision 44411
Added by Koichi Sasada about 1 year ago

  • vm_insnhelper.c (argument_error): insert dummy frame to make a backtrace object intead of modify backtrace string array. [Bug #9295]
  • test/ruby/test_backtrace.rb: add a test for this patch. fix test to compare a result of Exception#backtrace with a result of Exception#backtrace_locations.

History

#1 Updated by Koichi Sasada about 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r44411.
Tsuyoshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • vm_insnhelper.c (argument_error): insert dummy frame to make a backtrace object intead of modify backtrace string array. [Bug #9295]
  • test/ruby/test_backtrace.rb: add a test for this patch. fix test to compare a result of Exception#backtrace with a result of Exception#backtrace_locations.

#2 Updated by Tsuyoshi Sawada about 1 year ago

Thank you for the quick action, but the problem still remains in ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]. It still returns nil.

#3 Updated by Koichi Sasada about 1 year ago

(2013/12/26 13:15), sawa (Tsuyoshi Sawada) wrote:

Thank you for the quick action, but the problem still remains in ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]. It still returns nil.

it was pending to 2.1.1 because it is not critical.

--
// SASADA Koichi at atdot dot net

#4 Updated by Usaku NAKAMURA about 1 year ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: UNKNOWN

Also available in: Atom PDF