Fix call stack display for recursive function calls#203
Merged
gnidan merged 1 commit intocall-returnfrom Apr 2, 2026
Merged
Conversation
The call stack dedup logic compared only function name and call type, causing recursive calls (e.g. count -> count) to be collapsed into a single frame. Now also checks whether the previous frame was pushed on the immediately preceding step, which distinguishes the compiler's duplicate invoke contexts (caller JUMP + callee JUMPDEST on consecutive steps) from genuine recursive calls (same name but steps far apart). Fixed in both programs-react buildCallStack and web TraceDrawer's duplicated call stack logic.
caeef59 to
59dd341
Compare
Contributor
|
gnidan
commented
Apr 2, 2026
Member
Author
gnidan
left a comment
There was a problem hiding this comment.
Dedup logic looks correct. Confirmed from the compiler side:
-
bugc emits invoke context on the caller JUMP (
terminator.ts:271) and the callee entry JUMPDEST (function.ts:76). These are always consecutive EVM trace steps since JUMP lands directly on JUMPDEST. -
The
stepIndex === i - 1condition correctly distinguishes the JUMP→JUMPDEST duplicate (consecutive, same identifier) from recursive calls (non-consecutive, same identifier). No edge cases I can see — mutual recursion uses different identifiers, and self-recursion always has many steps between the outer call's JUMPDEST and the inner call's JUMP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stepIndex === i - 1to distinguish compiler-emitted duplicate invoke contexts (caller JUMP + callee JUMPDEST on consecutive steps) from genuine recursive calls (same function name but steps far apart)programs-react/utils/mockTrace.tsandweb/TraceDrawer.tsx