Skip to content

Fix stack trace frame names to show enclosing function instead of callee#652

Open
stephenamar-db wants to merge 1 commit intomasterfrom
stack/fixs
Open

Fix stack trace frame names to show enclosing function instead of callee#652
stephenamar-db wants to merge 1 commit intomasterfrom
stack/fixs

Conversation

@stephenamar-db
Copy link
Collaborator

Summary

  • Rework Error.formatError to label each stack frame with the enclosing function (the function whose body contains that position) instead of the callee (the function being called). This matches the convention used by Java/Python stack traces.
  • The fix scans frames outermost-to-innermost to compute the enclosing scope for each position. Builtin calls (std.*), comprehensions, and default parameter evaluations are transparent and don't create new scopes. Consecutive same-scope frames are deduplicated.
  • Add regression test for cross-file max-stack-frames error (error.max_stack_cross_file).

Before

sjsonnet.Error: [search] Max stack frames exceeded.
    at [search].(b.jsonnet:5:37)
    at [std.objectHas].(b.jsonnet:5:25)
    at [method].(a.jsonnet:5:23)
    at [m].(a.jsonnet:9:2)
    at [<root>].(a.jsonnet:1:7)

After

sjsonnet.Error: [search] Max stack frames exceeded.
    at [method].(b.jsonnet:5:37)
    at [m].(a.jsonnet:5:23)
    at [<root>].(a.jsonnet:9:2)

Each [name] now reflects the function you are in, not the function you called.

Test plan

  • All existing JVM tests pass (140/140)
  • Updated 6 golden files to match corrected trace format
  • Added new regression test error.max_stack_cross_file covering cross-file recursive max-stack error

Stack traces previously labeled each frame with the name of the function
being called at that position, rather than the function containing that
position. This made traces confusing, especially for cross-file max-stack
errors where the frame name didn't match the file shown.

Rework formatError to scan frames from outermost to innermost, computing
the enclosing function scope for each position. Builtin calls (std.*),
comprehensions, and default parameter evaluations are transparent and
don't create new scopes. Consecutive same-scope frames are deduplicated.

Add regression test for cross-file max-stack-frames error.
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

Successfully merging this pull request may close these issues.

1 participant