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

Debugging Plots.jl, TimerOutputs.jl and CSV.jl crashes #56

Closed
KristofferC opened this issue May 13, 2019 · 14 comments · Fixed by #57
Closed

Debugging Plots.jl, TimerOutputs.jl and CSV.jl crashes #56

KristofferC opened this issue May 13, 2019 · 14 comments · Fixed by #57

Comments

@KristofferC
Copy link
Contributor

KristofferC commented May 13, 2019

Tried

julia> using Plots, MagneticReadHead

julia> @time @iron_debug plot(rand(5))
Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{Any, (597,)}[SSAValue(1), SSAValue(2), ....
rec_backtrace at /home/Administrator/buildbot/worker/package_win64/build/src\stackwalk.c:94
record_backtrace at /home/Administrator/buildbot/worker/package_win64/build/src\task.c:217 [inlined]
jl_throw at /home/Administrator/buildbot/worker/package_win64/build/src\task.c:417
jl_bounds_error_ints at /home/Administrator/buildbot/worker/package_win64/build/src\rtutils.c:183
getindex at .\array.jl:729 [inlined]
renumber_ssa at .\compiler/ssair\slot2ssa.jl:65 [inlined]
#241 at .\compiler/ssair\slot2ssa.jl:74 [inlined]
ssamap at .\compiler/ssair\ir.jl:429
renumber_ssa! at .\compiler/ssair\slot2ssa.jl:74 [inlined]
renumber_ssa! at .\compiler/ssair\slot2ssa.jl:73
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
construct_ssa! at .\compiler/ssair\slot2ssa.jl:859
just_construct_ssa at .\compiler/ssair\driver.jl:109
run_passes at .\compiler/ssair\driver.jl:114

on master of MRH.

See also #61 and #62

@oxinabox
Copy link
Owner

Thanks.
This tends to be that I broke one of the unwritten rules of when you are allowed to run Expr(:isdefined, :foo)
and hit the fallback SSAValue from JuliaLang/julia#31786.

Something will need to be added to:

function created_on(ir)

to handle whatever the cause of this is.

@oxinabox
Copy link
Owner

I am really struggling to make a MVE of this.
I can reproduct this with Plots,
but so far not with anything simpler.

@oxinabox
Copy link
Owner

I am pretty sure
#61 and #62 are also the same issue.

I need to sit down with someone who understands the optimizer (pokes @Keno)
and dig into which of its assumptions I am violating.

@oxinabox oxinabox changed the title Debugging Plots.jl crashes Debugging Plots.j, TimerOutputs and CSV.jl crashes Jul 13, 2019
@oxinabox
Copy link
Owner

I am going to close #61 and #62 just to keep the converstation in one place

@oxinabox
Copy link
Owner

Best MWE:

using MagneticReadHead, TimerOutputs
t = TimerOutput()
@run print_timer(t)

@oxinabox oxinabox changed the title Debugging Plots.j, TimerOutputs and CSV.jl crashes Debugging Plots.j, TimerOutputs.jl and CSV.jl crashes Jul 13, 2019
@oxinabox
Copy link
Owner

@oxinabox
Copy link
Owner

MWE:

using MagneticReadHead

function danger19()
    y=2
    function inner()
        h=y
        y=12
        return h
    end
    inner()
end 

@run danger19()

@oxinabox
Copy link
Owner

#57
solves the danger19
MWE,
but not the others.

@KristofferC
Copy link
Contributor Author

Don't think this should have been closed.

@oxinabox
Copy link
Owner

My latest MWE is

 @run TimerOutputs.print_header(stdout, 0.5, 0.1, 3, 3, 7, false, true, 11, true, "oio")

The extra confoudning thing is if I copy and paste the corresponding section of code
directy into the REPL the call to

@run print_header(stdout, 0.5, 0.1, 3, 3, 7, false, true, 11, true, "oio")

works fine

@KristofferC KristofferC changed the title Debugging Plots.j, TimerOutputs.jl and CSV.jl crashes Debugging Plots.jl, TimerOutputs.jl and CSV.jl crashes Jul 15, 2019
@KristofferC
Copy link
Contributor Author

KristofferC commented Jul 15, 2019

I tried on the CSV.jl example and it doesn't crash but it never seems to finish running either (waited 6-7 min).

@oxinabox
Copy link
Owner

@KristofferC was this with #68?
I am not particularly superised, there are some performance blackholes with compilation.
I belive they are just the extreme case of the sprand one you commented in the CompiledFrames thread.
A simple one is

julia> foo() = Complex.(rand(1,2), rand(1,2)) * rand(Int, 2,1);

julia> @btime foo();
  297.770 ns (9 allocations: 720 bytes)

julia> @btime Debugger.@run foo();
  15.472 ms (46982 allocations: 1.78 MiB)

julia> @time MagneticReadHead.@run foo()
  <Hangs for over 30 minutes before I stopped watching>

I think they are either bugs Cassette or in the compiler,
At some point I will switch off Cassette and on to IRTools I think.
IRTools, being a bit simpler, plays nicer with the compiler.
See JuliaDiff/ChainRules.jl#37

If you like you could try a few:
set_uninstrumented!(Base); set_uninstrumented!(CSV.Parsers) etc.
But that would throw off any benchmarks.

@KristofferC
Copy link
Contributor Author

Sorry, yes with #68 (I meant to comment on that PR)

@oxinabox
Copy link
Owner

#74 is the correct way to solve this,
and it does indeed solve it.

oxinabox added a commit that referenced this issue Aug 31, 2019
oxinabox added a commit that referenced this issue Aug 31, 2019
* Switch to compiler tools to determine what is defined where

* switch to cleaner method, and remove duplicates

* correct detection of defined slots

* Add test proving #56 is fixed

* load TimerOutputs for the tests that depend on that

* add TimerOutpputs to Test target
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