JuliaDebug / Gallium.jl

The Julia debugger
Other
174 stars 23 forks source link

Crashes at breakpoint on error with Gallium.breakpoint_on_error() #151

Closed Divisible8737 closed 8 years ago

Divisible8737 commented 8 years ago

I am using Julia Version 0.5.0-rc3+0 (2016-08-22 23:43 UTC) on x86_64-apple-darwin15.3.0 Perhaps this is related to #148

This is my first attempt to set a breakpoint with Gallium. I tried calling breakpoint_on_error(), then defined and ran the silly() function and got the following error:

julia> using Gallium

julia> Gallium.breakpoint_on_error()

_Gallium.Hooking.Hook(Ptr{Void} @0x000000010ca71d20,UInt8[0x55,0x48,0x89,0xe5,0x41,0x56,0x53,0x49,0x89,0xfe,0xe8,0x31,0xd5,0x01,0x00],Gallium.breakpoint_on_error_hit)_

julia> function silly()
       error()
       end

silly (generic function with 1 method)

julia> silly()

_ERROR: KeyError: key Ptr{Void} @0x000000010ca71d20 not found in pop!(::Dict{Ptr{Void},Gallium.Hooking.Hook}, ::Ptr{Void}) at ./dict.jl:717 in unhook(::Ptr{Void}) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:476 in breakpoint_on_error_hit(::Gallium.Hooking.Hook, ::Gallium.X86_64.ExtendedRegs) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Gallium.jl:938 in _callback(::Ptr{Void}) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:289 in callback(::Ptr{Void}) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:326_

Then I tried calling breakpoint_on_error() after the silly() function had been introduced and got a different error:

 julia> Gallium.breakpoint_on_error()

_Gallium.Hooking.Hook(Ptr{Void} @0x000000010ca71d20,UInt8[0x55,0x48,0x89,0xe5,0x41,0x56,0x53,0x49,0x89,0xfe,0xe8,0x31,0xd5,0x01,0x00],Gallium.breakpoint_on_error_hit)_

 julia> silly()

_ERROR: MethodError: no method matching start(::Gallium.NativeStack) Closest candidates are: start(::SimpleVector) at essentials.jl:170 start(::Base.MethodList) at reflection.jl:258 start(::IntSet) at intset.jl:184 ... in collect(::Base.Generator{Gallium.NativeStack,Gallium.##104#108}) at ./array.jl:300 in breakpoint_on_error_hit(::Gallium.Hooking.Hook, ::Gallium.X86_64.ExtendedRegs) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Gallium.jl:947 in _callback(::Ptr{Void}) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:289 in callback(::Ptr{Void}) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:326_

timholy commented 8 years ago

For me, even this "silly" example results in a segfault.

julia> versioninfo()
Julia Version 0.5.1-pre+2
Commit f0d40ec* (2016-09-20 03:34 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7 CPU       L 640  @ 2.13GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, westmere)

@Keno, does this work on OSX but not Linux? Need help debugging? (I see you've been working on rr, so maybe that's part of your strategy to debug this...) Since it feels like so much of the work must already be done, it sure would be nice to get this working.

Keno commented 8 years ago

Yeah, I'll look into this. There have just been large demands on my time lately ;).

timholy commented 8 years ago

No doubt. Just wondering if it's platform specific and you might need some info from folks with different platforms.

Keno commented 8 years ago

It is platform specific, but I should have everything I need to look into this

timholy commented 8 years ago

BTW for me it segfaults whether or not I turn on breakpointing before silly has been executed (i.e., doesn't seem to be JIT-related).

Keno commented 8 years ago

I suspect it's due to inference's use of errors causing recursive faults.

timholy commented 8 years ago

I wondered.

Before 0.5 got released I didn't think this was very pressing, BTW, because I was in a phase where I was rebuilding julia about 10x per day and this lost out to @show debugging due to the cost of precompilation. Now that I'm using the same julia for days on end (will the wonders never cease!) this becomes much more interesting again :wink:.

Divisible8737 commented 8 years ago

Oops, here is all my version info:

versioninfo()
Julia Version 0.5.1-pre+2
Commit f0d40ec (2016-09-20 03:34 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin15.3.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
mkborregaard commented 8 years ago

On my system

using Gallium
Gallium.breakpoint_on_error()
function silly()
    error()
end
silly()

simply causes the computer to hang, until it report that it has run out of diskspace (I normally have 6GB free, it is a small SSD).

julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, ivybridge)
mkborregaard commented 8 years ago

This is repeated exactly on my other mac, which is the same model just 2 years more recent.

iamed2 commented 8 years ago

I get the hanging with breakpoint_on_error(); seems to be some sort of infinite recursion as memory usage for julia climbs forever.

Divisible8737 commented 8 years ago

Did this fix work for other OSX users? I am getting a new error now:

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.1-pre+2 (2016-09-20 03:34 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit f0d40ec (21 days old release-0.5)
|__/                   |  x86_64-apple-darwin15.3.0

julia> using Gallium

julia> Gallium.breakpoint_on_error()
Gallium.Hooking.Hook(Ptr{Void} @0x0000000107a341b0,UInt8[0x55,0x48,0x89,0xe5,0x41,0x56,0x53,0x49,0x89,0xfe,0xe8,0x31,0xdd,0x01,0x00],Gallium.breakpoint_on_error_hit)

julia> function silly()
                     error()
                     end
silly (generic function with 1 method)

julia> silly()
ERROR: KeyError: key Ptr{Void} @0x0000000107a341b0 not found
 in pop!(::Dict{Ptr{Void},Gallium.Hooking.Hook}, ::Ptr{Void}) at ./dict.jl:717
 in unhook(::Ptr{Void}) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:476
 in breakpoint_on_error_hit(::Gallium.Hooking.Hook, ::Gallium.X86_64.ExtendedRegs) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Gallium.jl:938
 in _callback(::Ptr{Void}) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:289
 in callback(::Ptr{Void}) at /Users/y9KAaixxegjR/.julia/v0.5/Gallium/src/Hooking/Hooking.jl:326