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

Show Julia error backtrace in GAP #521

Open
ThomasBreuer opened this issue Sep 18, 2020 · 2 comments
Open

Show Julia error backtrace in GAP #521

ThomasBreuer opened this issue Sep 18, 2020 · 2 comments

Comments

@ThomasBreuer
Copy link
Member

This is a counterpart of issue #519, which requested to show GAP error backtrace in Julia.
It would be good to show also Julia error backrtace in GAP.
For example, pure Julia shows the following.

julia> sqrt(-1)
ERROR: DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:33
 [2] sqrt at ./math.jl:557 [inlined]
 [3] sqrt(::Int64) at ./math.jl:583
 [4] top-level scope at REPL[24]:1

Julia called from a GAP session shows the following (without the Julia stacktrace information).

gap> JuliaEvalString( "sqrt(-1)" )
> ;
Error, DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
not in any function at *stdin*:2
type 'quit;' to quit to outer loop
brk> 

Double indirection (call Julia from GAP from Julia) in a Julia session shows the following (without the inner Julia stacktrace information).

julia> GAP.evalstr( "JuliaEvalString( \"sqrt(-1)\" )")
ERROR: Error thrown by GAP: Error, DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
not in any function at stream:1

Stacktrace:
 [1] error(::String, ::String) at ./error.jl:42
 [2] error_handler() at /export/home/sam/gap/4.0/pkg/GAP.jl/src/GAP.jl:158
 [3] evalstr_ex at /export/home/sam/gap/4.0/pkg/GAP.jl/src/ccalls.jl:36 [inlined]
 [4] evalstr(::String) at /export/home/sam/gap/4.0/pkg/GAP.jl/src/ccalls.jl:63
 [5] top-level scope at REPL[2]:1

In order to show also the stacktrace information, we have to change the function handle_jl_exception in JuliaInterface.c. As far as I understand, also the entries of Base.catch_stack() have to be entered in the calls of showerror, but the documentation of Base.catch_stack (in Julia 1.4) contains a warning that this function is experimental in Julia 1.1. Can we rely on this function?

@fingolfin
Copy link
Member

The documentation for Base.catch_stack references JuliaLang/julia#29901 where it is renamed to current_exceptions, but they actually leave the old name in with a deprecation warning. So I think we should be safe to use it for now; dealing with a renaming is also easy enough.

@fingolfin
Copy link
Member

See also #45

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

No branches or pull requests

2 participants