Skip to content

Handle ExceptionStack in code_typed(err) #558

@vchuravy

Description

@vchuravy
julia> @cuda demo(A)
ERROR: InvalidIRError: compiling MethodInstance for demo(::CuDeviceVector{Float32, 1}) resulted in invalid LLVM IR
Reason: unsupported call to an unknown function (call to julia.new_gc_frame)
Reason: unsupported call to an unknown function (call to julia.push_gc_frame)
Reason: unsupported call to an unknown function (call to julia.get_gc_frame_slot)
Reason: unsupported call to an unknown function (call to julia.pop_gc_frame)
Hint: catch this exception as `err` and call `code_typed(err; interactive = true)` to introspect the erronous code with Cthulhu.j

Nowadays in the REPL the last error is in err (Not sure when that was added)

julia> err
1-element ExceptionStack:
InvalidIRError: compiling MethodInstance for demo(::CuDeviceVector{Float32, 1}) resulted in invalid LLVM IR
julia> code_typed(err; interactive = true)
ERROR: MethodError: no method matching code_typed_by_type(::Type{Tuple{Base.ExceptionStack, Vararg{Any}}}; interactive::Bool)

Closest candidates are:
  code_typed_by_type(::Type; optimize, debuginfo, world, interp) got unsupported keyword argument "interactive"
   @ Base reflection.jl:1381

Works:

code_typed(first(err.stack).exception; interactive = true)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions