Skip to content

Conversation

@Troublor
Copy link
Collaborator

Summary

When an inspector's call or create hook returns early (returns Some(outcome)), frame_init is skipped but frame_return_result is still called. This caused frame stack misalignment in the additional limit trackers, leading to a panic with "frame stack is empty".

Fix: Override inspect_frame_init in MegaEvm to call on_inspector_intercept() when the inspector intercepts a call/create. This pushes an empty frame to all trackers, keeping the stacks aligned so frame_return_result can pop normally.

Changes

  • Added on_inspector_intercept() method to AdditionalLimit, DataSizeTracker, KVUpdateCounter, and StateGrowthTracker
  • Overrode inspect_frame_init in MegaEvm to handle inspector early return
  • Added test test_inspector_early_return_with_additional_limits to validate the fix

When an inspector's call/create hook returns early, frame_init is
skipped but frame_return_result is still called. This caused frame
stack misalignment in additional limit trackers, leading to panic.

Fix by overriding inspect_frame_init to call on_inspector_intercept()
which pushes an empty frame, keeping the stacks aligned.
@Troublor Troublor merged commit 252a52c into main Dec 31, 2025
2 checks passed
@Troublor Troublor deleted the william/fix/inspector-intercept branch December 31, 2025 07:12
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.

3 participants