Skip to content

Commit

Permalink
fix regression in error line numbers
Browse files Browse the repository at this point in the history
see e.g. #922
  • Loading branch information
JeffBezanson committed Sep 25, 2015
1 parent 042c4d5 commit 35c5234
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4974,6 +4974,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
}
if (do_coverage)
coverageVisitLine(filename, lno);
ctx.lineno = lno;
}
if (jl_is_labelnode(stmt)) {
if (prevlabel) continue;
Expand Down
23 changes: 23 additions & 0 deletions test/backtrace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,26 @@ linenum = @__LINE__; f12977(; args...) = ()
loc = functionloc(f12977)
@test endswith(loc[1], "backtrace.jl")
@test loc[2] == linenum

code_loc(p, skipC=true) = ccall(:jl_lookup_code_address, Any, (Ptr{Void},Cint), p, skipC)

@noinline function test_throw_commoning(x)
if x==1; throw(AssertionError()); end
if x==2; throw(AssertionError()); end
end

let
local b1, b2
try
test_throw_commoning(1)
catch
b1 = catch_backtrace()
end
try
test_throw_commoning(2)
catch
b2 = catch_backtrace()
end
@test code_loc(b1[4])[1] == code_loc(b2[4])[1] == :test_throw_commoning
@test code_loc(b1[4])[3] != code_loc(b2[4])[3]
end

4 comments on commit 35c5234

@tkelman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same failure on osx travis, just took longer than the buildbots did https://travis-ci.org/JuliaLang/julia/jobs/82073804

@staticfloat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running this on OSX, it looks like jl_lookup_code_address isn't doing what we want it to do:

julia> b1                                                                        [1/90817]
14-element Array{Ptr{Void},1}:
 Ptr{Void} @0x0000000109d32786
 Ptr{Void} @0x0000000109cd0d2f
 Ptr{Void} @0x0000000109d2b54d
 Ptr{Void} @0x0000000109d2b8f5
 Ptr{Void} @0x0000000109d2b98a
 Ptr{Void} @0x0000000109d2cf6d
 Ptr{Void} @0x0000000109d2d138
 Ptr{Void} @0x0000000109d2cd8f
 Ptr{Void} @0x0000000109d3fc28
 Ptr{Void} @0x0000000109cd24f8
 Ptr{Void} @0x000000030e1ff875
 Ptr{Void} @0x000000030e1ff447
 Ptr{Void} @0x000000030e1f5502
 Ptr{Void} @0x0000000109d3394f

julia> code_loc(b1[4])
svec(symbol("???"),symbol("???"),4459772149,symbol(""),-1,true,4459772149)

I get ??? for every one of those addresses except 11 and 13:

julia> code_loc(b1[11])
svec(:eval_user_input,symbol("REPL.jl"),62,symbol(""),-1,false,13121878133)

julia> code_loc(b1[12])
svec(symbol("???"),symbol("???"),13121877063,symbol(""),-1,true,13121877063)

julia> code_loc(b1[13])
svec(:anonymous,symbol("REPL.jl"),92,symbol("task.jl"),90,false,13121836290)

@vtjnash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcc does inlining differently, so it ends up with a slightly different backtrace.

if you aren't on a buildbot (which uses system unwind), the libosxunwind backtrace should look like:

julia> code_loc(b1[1],false)
svec(:rec_backtrace,symbol("/Volumes/Lion/Users/jameson/Documents/julia/src/task.c"),515,symbol("/Volumes/Lion/Users/jameson/Documents/julia/src/task.c"),688,true,4364810246)

julia> code_loc(b1[2],false)
svec(:jl_throw_with_superfluous_argument,symbol("/Volumes/Lion/Users/jameson/Documents/julia/usr/lib/libjulia.dylib"),-1,symbol(""),-1,true,4364813401)

julia> code_loc(b1[3],false)
svec(:test_throw_commoning,:none,2,symbol(""),-1,false,13038241749)

julia> code_loc(b1[3],false)
svec(:test_throw_commoning,:none,2,symbol(""),-1,false,13038241749)

julia> code_loc(b1[4],false)
svec(:jlcall_test_throw_commoning_21852,symbol(""),-1,symbol(""),-1,true,13038306726)

julia> code_loc(b1[5],false)
svec(:jl_apply,symbol("/Volumes/Lion/Users/jameson/Documents/julia/src/interpreter.c"),55,symbol("/Volumes/Lion/Users/jameson/Documents/julia/src/interpreter.c"),65,true,4364788996)

@JeffBezanson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I guess the test should search for :test_throw_commoning.

Please sign in to comment.