-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unusual backtrace line numbers with macros #1334
Comments
Remember that the problematic call occurs within an expansion of the It appears that you are trying to save the results from chold in an array but it would need to be an array of julia> typeof(chold(apd))
CholeskyDense{Float64} to be able to do that. Also, the Assuming that the calculation does not involve generating random numbers I would do the timing in one loop and the comparison of the results to the desired value externally. julia> chold(apd)
CholeskyDense{Float64}(100x100 Float64 Array:
10.7632 -0.0556399 0.424147 -0.673008 : -0.328331 0.329383 0.561125 0.235107
0.0 10.358 -0.184153 1.12445 -0.211135 0.680397 -1.50525 -0.77154
0.0 0.0 10.8046 -1.69622 1.2341 1.38032 -0.607595 -0.922997
0.0 0.0 0.0 9.74493 -0.123586 -0.60327 0.745185 1.28362
0.0 0.0 0.0 0.0 1.58217 -0.158097 1.87286 1.8869
0.0 0.0 0.0 0.0 : 0.308013 -0.75288 0.547033 1.77772
0.0 0.0 0.0 0.0 -2.32311 0.695899 -1.18943 -1.26152
0.0 0.0 0.0 0.0 0.173486 0.833139 -0.982545 -0.971247
0.0 0.0 0.0 0.0 1.01998 0.515218 -0.364214 0.905679
0.0 0.0 0.0 0.0 -1.31963 0.17844 1.27579 -0.654185
:
0.0 0.0 0.0 0.0 : 1.436 1.47801 -1.08752 -0.000612769
0.0 0.0 0.0 0.0 -0.427271 1.58678 -0.682428 1.30084
0.0 0.0 0.0 0.0 0.862027 0.499158 0.389469 -0.450842
0.0 0.0 0.0 0.0 -0.838898 0.498183 0.552315 0.830528
0.0 0.0 0.0 0.0 1.56324 0.529648 -2.11759 0.251053
0.0 0.0 0.0 0.0 : -1.07418 -0.258497 1.93681 -1.49743
0.0 0.0 0.0 0.0 1.35022 -0.502995 -0.262886 -0.0517407
0.0 0.0 0.0 0.0 0.0 1.06416 1.58952 -0.679477
0.0 0.0 0.0 0.0 0.0 0.0 2.13802 -0.683735
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.459775 ,true)
julia> [@elapsed chold(apd) for k in 1:10]
10-element Float64 Array:
0.000403166
0.000166893
0.000160933
0.000161886
0.000162125
0.000156879
0.000162125
0.00016284
0.0101092
0.000149012 |
Ah, the macro expansion is what screws it up. I see. Are macros not And yes, I realized the code wasn't doing what I wanted it do; it still On Thu, Oct 4, 2012 at 12:04 PM, dmbates [email protected] wrote:
|
the reported line number is from the elapsed macro in base/util.jl @JeffBezanson you've already done such a great job improving line number reporting, can it be fixed here too? shorter code example: julia> times = [@elapsed push!([1,],2.4) for k = 2]
InexactError()
in push! at array.jl:649
in push at deprecated.jl:8
in anonymous at no file:49 #<-- the error is here |
Bump. Any chance this can be fixed for 0.3? JuMP's heavy use of macros leads to nearly useless error messages for users. |
Is there any hope that improvements we make for precompiled code line numbers can improve this situation? |
I don't have time to dig into this myself, but for anyone who is interested: a little poking makes me think there are two pieces to this problem, and that perhaps one might not be so hard. Check out the error that @vtjnash's example gives:
The line number 56 comes from Now check this out:
You can see that the generated expression actually has the information about How the If I had time to tackle this, I'd start by looking at |
I dug into this a bit. To me it seems that Julia is doing everything it should in terms of documenting where code comes from in the generated expressions. Consider: julia> macroexpand(:(function myfunc()
times = [@elapsed push!([1,],2.4) for k = 2]
times
end))
:(function myfunc() # none, line 2:
times = $(Expr(:comprehension, :(begin # util.jl, line 51:
local #56#t0 = Base.time_ns() # line 52:
local #57#val = push!([1],2.4) # line 53:
Base./(Base.-(Base.time_ns(),#56#t0),1.0e9)
end), :(k = 2))) # line 3:
times
end) It took me a little to remember/understand this, but the Here's a longer block: julia> macroexpand(:(function myfunc(t)
times = [@elapsed begin
y = t+2
push!([1],2.4)
end for k=2]
times
end))
:(function myfunc(t) # none, line 2:
times = $(Expr(:comprehension, :(begin # util.jl, line 51:
local #58#t0 = Base.time_ns() # line 52:
local #59#val = begin # none, line 3:
y = t + 2 # line 4:
push!([1],2.4)
end # line 53:
Base./(Base.-(Base.time_ns(),#58#t0),1.0e9)
end), :(k = 2))) # line 6:
times
end) Again, it's clearly documenting where code comes from. So now let's see if this information gets recovered from the backtraces. Using the
You can see that there's just not very much useful information in this backtrace. This probably can't be fixed until we switch to MCJIT. |
I think the information gets actively stripped later on, since we assume the lines in an emitted function all came from the same function/file while emitting the line info, and again later while matching instructions to their source line |
Ah! You are right. Looking at
You can see that after the switch to Am I right in remembering/guessing lowering is performed in the Scheme code? If it's there, I fear it's a bit beyond me to try to fix it (at least, not without a serious investment).
Is there any chance this is related to our truncated backtraces (#3469)? In that issue, I noted there seems to be some association with inlining, and the common feature with the issue here is that code is coming from "elsewhere." That said, I wasn't able to find any evidence for this view in |
If you look at I don't think this is related to truncated backtraces |
Thanks, that was very informative. I still have only a vague understanding of what's going on, but IIUC we're not relying on the fact that a FuncInfo has only a single name/filename. We're getting funcname/filename info from the context stored in |
I guess my plea to fix this in 0.3 didn't go through, trying again for 0.4 :) |
@mlubin, while I've dug into this a bit myself in the past, the whole Array nirvana thing (along with miscellaneous other contributions) is already more than maxing out the time I have available for "core julia" stuff. Care to dive in and try to fix this yourself? |
@timholy any ideas where the general area of the problem is? |
The tests above contain the entire sum of my knowledge on this issue. |
I didn't want to open a new issue, but I have the feeling, that line numbers got worse lately.
There is a lot missing here! in convert at pointer.jl:7 #didn't show up the time I got decent stack traces, though
OpenCL\src\types.jl on line 143
OpenCL\src\context.jl on line 176
OpenCL\src\context.jl on line 90
InteropContext.jl, in expression starting on line 17
C:\Users\Sim\Desktop\Julia\InteropContext.jl, in expression starting on line 21 "minimal" example: I don't know what's going on here... I had a version, where it gave me the correct line numbers, but I can't reproduce it right now. Julia Version 0.4.0-dev+2523
Commit e26eb53* (2015-01-06 05:57 UTC)
Platform Info:
System: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.3 Best, |
If you can come up with an example that doesn't use code from a package, it'll be much easier to try bisecting this. |
Yes I know, but this requirement hold me back from posting any bug report 2015-01-14 12:36 GMT+01:00 Tony Kelman [email protected]:
|
So I thought this is better than nothing. I must admit I haven't tried it 2015-01-14 13:29 GMT+01:00 Simon Danisch [email protected]:
|
Okay, okay, I'll fiddle with things and try to see if I can find any commits since the 0.4-dev branch that give better backtraces there. You could try with older nightlies from http://s3.amazonaws.com/julianightlies, but it looks like the oldest ones still there are about a month old. I do think your specific problem should probably be a separate issue though, since it's likely platform-dependent. |
@JeffBezanson I guess I'll go find my threadbare Scheme hat. @ScottPJones the patch probably applies cleanly, but I wouldn't use it yet. As per above, it relies on a faulty assumption. (also makes the REPL noisy, hard-codes an important test, probably leaks, etc.). |
Another example from julia-users: https://groups.google.com/d/msg/julia-users/GXHm6sqR3YI/oF990MaNAQAJ |
I could use some help with lowering these
|
@JeffBezanson, if you have any time to share thoughts on the However, I am hopeful that there is some room for improvement in the current scheme:
|
Related to the second idea: strip all non-filename line nodes when splicing code. Then we could make the original assumption that unattached line nodes are only at top-level scope, and still trace to the definition location. (downside: consecutive non-toplevel filename line nodes could be ambiguous -- nested vs. spliced -- but that would not be terrible because the toplevel line would always be correct) |
Utilizes the DebugLoc "inlinedAt" information added in the previous commit to provide line information for inlined code. For functions where this information is available, we now print both the inlinee origin and the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
Utilizes the DebugLoc "inlinedAt" information added in the previous commit to provide line information for inlined code. For functions where this information is available, we now print both the inlinee origin and the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
Utilizes the DebugLoc "inlinedAt" information added in the previous commit to provide line information for inlined code. For functions where this information is available, we now print both the inlinee origin and the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
Utilizes the DebugLoc "inlinedAt" information added in the previous commit to provide line information for inlined code. For functions where this information is available, we now print both the inlinee origin and the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
Utilizes the DebugLoc "inlinedAt" information added in the previous commit to provide line information for inlined code. For functions where this information is available, we now print both the inlinee origin and the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
Utilizes the DebugLoc "inlinedAt" information added in the previous commit to provide line information for inlined code. For functions where this information is available, we now print both the inlinee origin and the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
Utilizes the DebugLoc "inlinedAt" parameter to remember inlining location in addition to source code origin. When available, we now print both the inlinee origin below the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
Utilizes the DebugLoc "inlinedAt" parameter to remember inlining location in addition to source code origin. When available, we now print both the inlinee origin below the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
Utilizes the DebugLoc "inlinedAt" parameter to remember inlining location in addition to source code origin. When available, we now print both the inlinee origin below the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
Utilizes the DebugLoc "inlinedAt" parameter to remember inlining location in addition to source code origin. When available, we now print both the inlinee origin below the top-level call site. Mostly addresses #1334. (this does not handle nested inlines, which may require deeper changes)
@ihnorton, you should do the honors here. |
OK to close this? |
Ok 😄 |
New backtraces are really awesome btw! |
I've noticed that Julia's backtrace line numbers don't alway make sense. For instance, in the following short program (named
lapack_perf.jl
) and ignoring the actual errors in the code:I get the following backtrace:
This all looks fine and good until we see the
in test_chold at /Users/sabae/Desktop/lapack_perf.jl:49
line; Clearly this file doesn't have a line 49.EDIT: This is due to macros, as @dmbates states. Is there a better way to effect line-printing with macros (which are very helpful and therefore likely to be used extensively)?
The text was updated successfully, but these errors were encountered: