8000 BEAM runtime errors with a non-string reason print as `Internal error: ~p`, with no source position · Issue #750 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

BEAM runtime errors with a non-string reason print as Internal error: ~p, with no source position #750

Open

Description

@akoskovacs

When a compiled program dies with an Erlang reason that is not a string (function_clause, badarith, badmatch, {case_clause, …}), the runner prints it with ~p under "Internal error":

$ kex clause.kex          # area/1 called with a constructor it has no clause for
Internal error: function_clause

The format is in runBuiltProgram (src/driver/compile.cxx):

_R -> io:format(standard_error, "Internal error: ~p~n", [_R])

So a fault in user code reads like a compiler crash and carries no file:line:col, which Kex's own runtime errors do (app.kex:8:26: runtime error: …).

Suggestion: translate the common BEAM reasons into a Kex runtime error naming the function and position (the stack trace has module and function; lowering already passes positions to the kex_intrinsic_* calls), and keep "Internal error" for reasons that really are internal.

Related: #704 (runtime faults should be rescuable; BEAM reasons inconsistent).

Seen on 0.4.0-rc.4 (0292db50), macOS arm64, OTP 29.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0