Feature #7435
closed
Exceptions should have backtrace_locations
Added by sam.saffron (Sam Saffron) almost 12 years ago.
Updated over 11 years ago.
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.
ouch, this was meant to be a feature req not a bug ... cant figure out how to change
- 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
- Target version changed from 2.0.0 to 2.6
Sorry, meant next minor, as #7051
(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
- Status changed from Assigned to Rejected
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.
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.
Why is this issue closed? Is this problem solved? I think it is a very important feature that is missing.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0