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

Problem with _reformat_bt? #32678

Closed
vtjnash opened this issue Jul 25, 2019 · 7 comments · Fixed by #33524
Closed

Problem with _reformat_bt? #32678

vtjnash opened this issue Jul 25, 2019 · 7 comments · Fixed by #33524
Assignees
Labels
priority This should be addressed urgently

Comments

@vtjnash
Copy link
Member

vtjnash commented Jul 25, 2019

test failure appears on https://build.julialang.org/#/builders/76/builds/449/steps/8/logs/stdio, inhibiting fixing the buildbot CI since we can't see the real error:

fatal: error thrown and no exception handler available.
BoundsError(a=Array{Any, (0,)}[], i=(1,))
rec_backtrace at /buildworker/worker/package_linux64/build/src/stackwalk.c:94
record_backtrace at /buildworker/worker/package_linux64/build/src/task.c:217 [inlined]
jl_throw at /buildworker/worker/package_linux64/build/src/task.c:454
jl_bounds_error_ints at /buildworker/worker/package_linux64/build/src/rtutils.c:183
getindex at ./array.jl:742 [inlined]
_reformat_bt at ./error.jl:67
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2049 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2213
catch_backtrace at ./error.jl:91
task_done_hook at ./task.jl:318
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2049 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2213
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1630 [inlined]
jl_finish_task at /buildworker/worker/package_linux64/build/src/task.c:174
start_task at /buildworker/worker/package_linux64/build/src/task.c:614
unknown function (ip: 0xffffffffffffffff)
@vtjnash vtjnash added priority This should be addressed urgently good first issue Indicates a good issue for first-time contributors to Julia labels Jul 25, 2019
@elalaouifaris
Copy link
Contributor

Hi,
I would like to help on a first issue in Julia. This one is marked both as good first issue and priority.
So I would start here.

However I can't see where to start from the above comment. Could you give me more info on how to start working on this please?

Thanks

@mbauman
Copy link
Member

mbauman commented Aug 14, 2019

Welcome! I'm not sure how good of a first issue this actually is. The problem is here:

julia/base/error.jl

Lines 67 to 69 in 7615d4c

push!(ret, InterpreterIP(
bt2[j],
bt[i+2]))

Apparently under some conditions this will throw a bounds error. It's particularly hard for a new contributor as we don't have a minimal example that causes the error — it's something that the code coverage bot is doing that is causing it. So you're welcome to try and figure out if there are some cases where that'll try to index into an empty array at index 1… but it's pretty gnarly code. In fact, it's probably the caller of _reformat_bt that is passing it a bad argument pair, and it's not immediately obvious who that caller is.

@mbauman mbauman added help wanted Indicates that a maintainer wants help on an issue or pull request and removed good first issue Indicates a good issue for first-time contributors to Julia labels Aug 14, 2019
@KestutisMa
Copy link

When different modules export same methods. Using sysimage compiled with Makie and Interact shows:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.0-DEV.142 (2019-09-15)
 _/ |\__'_|_|_|\__'_|  |  Commit ed3aefe42c (0 days old master)
|__/                   |

julia> using Interact

julia> using Makie

julia> ui = button();
WARNING: both Makie and Interact export "button"; uses of it in module Main must be qualified
fatal: error thrown and no exception handler available.
BoundsError(a=Array{Any, (0,)}[], i=(1,))

@KestutisMa
Copy link

Looks like error is thrown at any ambiguous input (using sysimage compiled with Makie and Interact):

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.0-DEV.142 (2019-09-15)
 _/ |\__'_|_|_|\__'_|  |  Commit ed3aefe42c (0 days old master)
|__/                   |

julia> aaa
fatal: error thrown and no exception handler available.
BoundsError(a=Array{Any, (0,)}[], i=(1,))

@JeffBezanson
Copy link
Member

I found a reliable (on my system at least) way to trigger this. Apply:

diff --git a/base/error.jl b/base/error.jl
index c0a37ed..b651ca6 100644
--- a/base/error.jl
+++ b/base/error.jl
@@ -108,7 +108,7 @@ function catch_backtrace()
     bt = Ref{Any}(nothing)
     bt2 = Ref{Any}(nothing)
     ccall(:jl_get_backtrace, Cvoid, (Ref{Any}, Ref{Any}), bt, bt2)
-    return _reformat_bt(bt[], bt2[])
+    return _reformat_bt(bt[]::Vector{Ptr{Cvoid}}, bt2[]::Vector{Any})
 end

So all that does is add correct type annotations. When I build, I get the error in the OP during generate_precompile. Even better, you can start julia with ./julia -J usr/lib/julia/sys.ji and then it happens as soon as you trigger any error:

julia> x
fatal: error thrown and no exception handler available.
BoundsError(a=Array{Any, (0,)}[], i=(1,))

I suspect this might be a codegen or possibly LLVM bug.

@JeffBezanson
Copy link
Member

Digging in a bit with rr, it looks like error.jl:73:

        if ip == Ptr{Cvoid}(-1%UInt)

is comparing to 0 instead of to -1:

   0x00007f157368ffdd <+205>:	mov    0x0(%r13),%rcx
   0x00007f157368ffe1 <+209>:	mov    -0x8(%rcx,%r15,8),%r12
   0x00007f157368ffe6 <+214>:	test   %r12,%r12
   0x00007f157368ffe9 <+217>:	mov    %r8,0x20(%rbx)
=> 0x00007f157368ffed <+221>:	je     0x7f15736900c0 <japi1__reformat_bt_909+432>

I believe that test instruction is comparing the pointer loaded from bt to 0.

@JeffBezanson
Copy link
Member

Oh right, of course: this is because we serialize pointers as NULL...

@JeffBezanson JeffBezanson removed the help wanted Indicates that a maintainer wants help on an issue or pull request label Oct 10, 2019
@JeffBezanson JeffBezanson self-assigned this Oct 10, 2019
JeffBezanson added a commit that referenced this issue Oct 10, 2019
Also change `jl_get_backtrace` to return a pair of values instead of
mutating.
JeffBezanson added a commit that referenced this issue Oct 11, 2019
Also change `jl_get_backtrace` to return a pair of values instead of
mutating.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority This should be addressed urgently
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants