Project

General

Profile

Actions

Feature #7435

closed

Exceptions should have backtrace_locations

Added by sam.saffron (Sam Saffron) about 12 years ago. Updated over 11 years ago.

Status:
Rejected
Target version:
[ruby-core:50093]

Description

Further to http://bugs.ruby-lang.org/issues/7051

def boom
raise "boom"
end

begin
boom
rescue => e
p e.backtrace
end

["t.rb:2:in boom'", "t.rb:6:in '"]

It seems exceptions still store backtraces in strings, shouldn't the backtrace be stored in RubyVM::Backtrace::Location objects and then optionally grabbed using backtrace_locations or backtrace depending on how you feel?

This means exceptions could be more efficient as filenames could easily be pinned in memory leading to significantly reduced allocation for exceptions.

Updated by sam.saffron (Sam Saffron) about 12 years ago

ouch, this was meant to be a feature req not a bug ... cant figure out how to change

Updated by zzak (zzak _) about 12 years ago

  • Tracker changed from Bug to Feature
  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to ko1 (Koichi Sasada)
  • Target version set to 2.0.0

Updated by zzak (zzak _) about 12 years ago

  • Target version changed from 2.0.0 to 2.6

Sorry, meant next minor, as #7051

Updated by ko1 (Koichi Sasada) about 12 years ago

(2012/11/26 7:02), sam.saffron (Sam Saffron) wrote:

This means exceptions could be more efficient as filenames could easily be pinned in memory leading to significantly reduced allocation for exceptions.

Current implementation does not make String array.
Please run the following code:


def foo
raise
end

begin
foo
rescue => e

e.backtrace # (X)

ObjectSpace.each_object(Array){|ary|
if ary.find{|obj| obj.is_a?(String) and /foo/ =~ obj}
p ary
end
}
end


If you run (X), then the code prints out backtrace object.

--
// SASADA Koichi at atdot dot net

Updated by ko1 (Koichi Sasada) about 12 years ago

  • Status changed from Assigned to Rejected

Updated by ko1 (Koichi Sasada) about 12 years ago

One more comment.

Exception class has Exception#set_backtrace method, which set backtrace using string array. It conflicts with locations.

We need to solve this issue to support Exception#backtrace_locations.

Updated by headius (Charles Nutter) almost 12 years ago

I wish I had seen this before 2.0.0!

Perhaps set_backtrace should just cause backtrace_locations to return an empty array?

I really, really wish backtrace_locations had gotten into 2.0.0, so let's try to make this happen for 2.1.

Updated by sawa (Tsuyoshi Sawada) over 11 years ago

Why is this issue closed? Is this problem solved? I think it is a very important feature that is missing.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0