Skip to content
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

Compilation errors in timed function calls yield "broken" stacktraces #77

Open
sloede opened this issue Feb 18, 2020 · 2 comments · May be fixed by #164
Open

Compilation errors in timed function calls yield "broken" stacktraces #77

sloede opened this issue Feb 18, 2020 · 2 comments · May be fixed by #164

Comments

@sloede
Copy link
Contributor

sloede commented Feb 18, 2020

When there is an error within a function call timed with @timeit, sometimes the stacktraces do not report correct file names and line numbers anymore.

mwe.jl

using TimerOutputs

function foo(::Float64) end

@timeit "foo" foo(1)

Running juila mwe.jl yields

ERROR: LoadError: MethodError: no method matching foo(::Int64)
Closest candidates are:
  foo(::Float64) at /path/to/mwe.jl:3
Stacktrace:
 [1] top-level scope at /home/user/.julia/packages/TimerOutputs/7Id5J/src/TimerOutput.jl:214
 [2] include at ./boot.jl:328 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1105
 [4] include(::Module, ::String) at ./Base.jl:31
 [5] exec_options(::Base.JLOptions) at ./client.jl:287
 [6] _start() at ./client.jl:460
in expression starting at /path/to/mwe.jl:5

Some initial testing suggests that this is only a problem if the error occurs at the "function selection/argument evaluation level", i.e., if there is an error during the argument evaluation or if (as in this case) no matching method could be found. I was not able to reproduce this behavior if there are compilation errors from within the timed function.

@antoine-levitt
Copy link

I don't know if it's the same as this, but

julia> @timeit to "test" begin error() end
Stacktrace:
 [1] error()
   @ Base ./error.jl:44
 [2] macro expansion
   @ REPL[6]:1 [inlined]
 [3] top-level scope
   @ ~/.julia/packages/TimerOutputs/jgSVI/src/TimerOutput.jl:236
 [4] top-level scope
   @ ~/.julia/packages/Infiltrator/R8I9c/src/Infiltrator.jl:632

There is no such thing with a @views for instance.

@antoine-levitt
Copy link

This seems to be because TimerOutput wraps the code inside a tryfinally block, as seen from @macroexpand. Not sure how to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants