Skip to content

Add default MethodError handler for --trim executables #58450

@topolarity

Description

@topolarity

--trim does not statically forbid MethodErrors (it just makes sure that we can execute your code as an ahead-of-time, even if that's throwing an error).

As a result, it's common to see errors like this:

$ ./demo
fatal: error thrown and no exception handler available.
Core.MethodError(f=Base.var"#getindex"(), args=(nothing, 1), world=0x000000000000c37d)
jl_method_error_bare at /cache/build/default-aws-aarch64-ci-0-4/julialang/julia-release-1-dot-12/src/gf.c:2529
jl_method_error at /cache/build/default-aws-aarch64-ci-0-4/julialang/julia-release-1-dot-12/src/gf.c:2547
jl_f_throw_methoderror at /cache/build/default-aws-aarch64-ci-0-4/julialang/julia-release-1-dot-12/src/builtins.c:587 [inlined]
jl_f_throw_methoderror at /cache/build/default-aws-aarch64-ci-0-4/julialang/julia-release-1-dot-12/src/builtins.c:583
...
main at /demo.jl:52
main at ./demo(unknown line)
unknown function (ip: 0x7fa122777f) at /lib/aarch64-linux-gnu/libc.so.6
__libc_start_main at /lib/aarch64-linux-gnu/libc.so.6 (unknown line)

For a lot of users, this feels like a segfault / crash and they might think something is wrong with their build system (or with --trim itself) - it would be much better to print this in a format similar to MethodError in normal Julia code so that this feels friendly and guides a user to fix their bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    error messagesBetter, more actionable error messagestrimmingIssues with trimming functionality or PR's relevant to its performance/functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions