Skip to content

Conversation

@maleadt
Copy link
Member

@maleadt maleadt commented Dec 3, 2020

This happens with PackageCompiler and modules that error during __init__ (which gets called way earlier if said modules are part of the system image). Before:

fatal: error thrown and no exception handler available.
#<null>
error at ./error.jl:33
__init__ at /home/tim/Julia/pkg/DummyPackage/src/DummyPackage.jl:4
jl_sysimg_fvars_base at /tmp/sys.so (unknown line)
_jl_invoke at /home/tim/Julia/src/julia/src/gf.c:2205 [inlined]
jl_apply_generic at /home/tim/Julia/src/julia/src/gf.c:2406
jl_apply at /home/tim/Julia/src/julia/src/julia.h:1701 [inlined]
jl_module_run_initializer at /home/tim/Julia/src/julia/src/toplevel.c:74
_julia_init at /home/tim/Julia/src/julia/src/init.c:796
repl_entrypoint at /home/tim/Julia/src/julia/src/jlapi.c:682
main at julia (unknown line)
__libc_start_main at /nix/store/a6rnjp15qgp8a699dlffqj94hzy1nldg-glibc-2.32/lib/libc.so.6 (unknown line)
_start at julia (unknown line)

After:

fatal: error thrown and no exception handler available.
InitError(mod=:DummyPackage, error=ErrorException("true"))
error at ./error.jl:33
__init__ at /home/tim/Julia/pkg/DummyPackage/src/DummyPackage.jl:4
jl_sysimg_fvars_base at /tmp/sys.so (unknown line)
_jl_invoke at /home/tim/Julia/src/julia/src/gf.c:2205 [inlined]
jl_apply_generic at /home/tim/Julia/src/julia/src/gf.c:2406
jl_apply at /home/tim/Julia/src/julia/src/julia.h:1701 [inlined]
jl_module_run_initializer at /home/tim/Julia/src/julia/src/toplevel.c:74
_julia_init at /home/tim/Julia/src/julia/src/init.c:796
repl_entrypoint at /home/tim/Julia/src/julia/src/jlapi.c:682
main at julia (unknown line)
__libc_start_main at /nix/store/a6rnjp15qgp8a699dlffqj94hzy1nldg-glibc-2.32/lib/libc.so.6 (unknown line)
_start at julia (unknown line)

At least the exception is there now.

cc @KristofferC

@maleadt maleadt added the error handling Handling of exceptions by Julia or the user label Dec 3, 2020
@maleadt maleadt requested a review from c42f December 3, 2020 14:35
Copy link
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks useful, I'm only confused that it's necessary — we seem to only call jl_no_exc_handler with either the current exception in task.c, or using jl_current_exception(). Or does PackageCompiler call jl_no_exc_handler?

After this change, it'll be unnecessary to pass jl_current_exception here (as this will be the default) so perhaps you could change those other couple of call sites too.

@maleadt maleadt force-pushed the tb/excstack_without_handler branch from 753989d to ec26f45 Compare December 4, 2020 09:56
@maleadt
Copy link
Member Author

maleadt commented Dec 4, 2020

we seem to only call jl_no_exc_handler with either the current exception in task.c, or using jl_current_exception()

During jl_module_run_initializer, we call jl_rethrow_other with jl_current_exception indeed, but that just puts the exception on the top of the stack and continues to call throw_internal(NULL) which then ends up in jl_no_exc_handler with a NULL exception.

Copy link
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. Yes it appears the use of NULL to signify "this is a rethrow" has led to confusion here.

Well this code LGTM (other than the comment about NULL denoting the top of the stack. That's either wrong, or I'm confused by it :-) )

@maleadt maleadt force-pushed the tb/excstack_without_handler branch from ec26f45 to aaab77e Compare December 4, 2020 10:34
@maleadt
Copy link
Member Author

maleadt commented Dec 4, 2020

Thanks! I updated the comment to reflect NULL exceptions are only used for rethrowing.

@c42f
Copy link
Member

c42f commented Dec 4, 2020

Looks great 👍

@maleadt maleadt merged commit 56dd7d7 into master Dec 4, 2020
@maleadt maleadt deleted the tb/excstack_without_handler branch December 4, 2020 13:18
@vchuravy vchuravy mentioned this pull request Jan 21, 2021
27 tasks
NHDaly pushed a commit to NHDaly/julia that referenced this pull request Jan 21, 2021
…_handler

Report the top of the exception stack when there's no handler.

-------

Backport JuliaLang#38679 into release-1.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

error handling Handling of exceptions by Julia or the user

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants