History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-2112
Type: Bug Bug
Status: Open Open
Priority: Critical Critical
Assignee: Vladimir Sizikov
Reporter: Ana Nelson
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
JRuby

Incorrect lines in exception backtraces

Created: 13/Feb/08 10:38 AM   Updated: 06/Oct/08 09:26 PM
Component/s: Core Classes/Modules
Affects Version/s: JRuby 1.1RC1
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. File example.rb (0.5 kb)

Environment: ruby 1.8.6 (2008-01-07 rev 5512) [i386-jruby1.1RC1] OSX 10.4.11
Issue Links:
Duplicate
 
dependent
 


 Description  « Hide
In the test case attached, the error is being raised by "+" on line 2 of the script, but the error is reported incorrectly as coming from "each" on line 1. This makes it difficult to troubleshoot since you think there's something wrong with the array you are calling .each on.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Vladimir Sizikov - 15/Feb/08 12:26 PM
I wouldn't say this is of trivial priority. It's actually very serious. Basically, stacktraces are just wrong even in many cases:

This one:
"hello".sub(/l/, 5)

Or this one:
1 / 0

This one:
[4,5,6] + 5

This one:
def my_meth
[4,5,6] + 5
end
my_meth


Vladimir Sizikov - 15/Feb/08 01:17 PM - edited
Here's what happens.
Let's say we have the following example:
"hello".sub(/l/, 5)

The frames:
1) file:1
2) String#sub

Then, say, an exception inside div hapens. We add the second frame once again:
1) file:1
2) String#sub
3) String#sub

Then, we calculate backtraces, and the code in ThreadContext.addBackTraceElement basically filters out the last frame.

The quick and dirty fix is here:
http://pastie.org/152801

Will investigate further.


Vladimir Sizikov - 19/Feb/08 04:56 AM
Adjusted the subject to better reflect the situation.

Vladimir Sizikov - 19/Feb/08 05:04 AM
Another reason for missed traces is that many core methods are not marked with frame=true or backtrace=true, and hence missing in the stack trace. E.g., "+" is not marked and never appears in the stack trace.

Vladimir Sizikov - 19/Feb/08 03:32 PM
Partially fixed in rev. r5974. At least exception out of "hello".sub(/l/, 5) is printed properly now.
For '+', need to add appropriate annotations to methods.

Charles Oliver Nutter - 06/Oct/08 09:26 PM
Not a compiler issue; more related to our core classes not having backtrace frames in all cases.