Skip to content

Make it easier to track down errors that occur in a thunk #57

Closed
@oxinabox

Description

@oxinabox

Consider:

julia> extern(foo())
ERROR: ArgumentError: invalid rational: zero(Int64)//zero(Int64)
Stacktrace:
 [1] __throw_rational_argerror(::Type) at ./rational.jl:19
 [2] Rational at ./rational.jl:14 [inlined]
 [3] Rational at ./rational.jl:21 [inlined]
 [4] //(::Int64, ::Int64) at ./rational.jl:44
 [5] (::var"#13#14")() at /Users/oxinabox/.julia/packages/ChainRulesCore/LC8Sv/src/differentials.jl:243
 [6] (::Thunk{var"#13#14"})() at /Users/oxinabox/.julia/packages/ChainRulesCore/LC8Sv/src/differentials.jl:250
 [7] extern(::Thunk{var"#13#14"}) at /Users/oxinabox/.julia/packages/ChainRulesCore/LC8Sv/src/differentials.jl:251
 [8] top-level scope at REPL[9]:1

There was an error thrown within the thunk.
but the stacktrace tells me nothing about how to find the thunk.

It doesn't tell me wher the Thunk was, nor what it contained.

There are a few things we can investigate:

  1. (somehow) make it so the line numbers for the thunk's inner function in [5] reflect where the @thunk was rather than its contents
  2. use source.__line__ and source.__file__ to actually include that in the functions name
  3. include the expression wrapped in the functions name
  4. Have a way to disable thiunking and make it eager. I think this can be done by having disable_thunking()=@eval macro thunk(x) x end and matching enable_thunk() to restore original definition

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions