Debugging: fix panic in align_atomic_addr when guest-debug is enabled.#12815
Merged
alexcrichton merged 1 commit intobytecodealliance:mainfrom Mar 21, 2026
Merged
Debugging: fix panic in align_atomic_addr when guest-debug is enabled.#12815alexcrichton merged 1 commit intobytecodealliance:mainfrom
alexcrichton merged 1 commit intobytecodealliance:mainfrom
Conversation
We have an invariant that the `stack_shape` and `stack` stacks are the same length whenever we emit debug tags. The invariant is temporarily broken when any result is pushed (the value stack becomes longer) but then restored between each instruction. Now that traps take debug tags too, we have to be careful to maintain the invariant. Usually no new results are pushed before checking for trap-conditions. However `align_atomic_addr` popped then re-pushed a value on the value stack before a trap check; this could cause the invariant to be violated and hence lead to a panic. This PR instead uses the `peek1` helper to maintain the shape stack entry. Fixes bytecodealliance#12808.
alexcrichton
approved these changes
Mar 21, 2026
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.
We have an invariant that the
stack_shapeandstackstacks are the same length whenever we emit debug tags. The invariant is temporarily broken when any result is pushed (the value stack becomes longer) but then restored between each instruction.Now that traps take debug tags too, we have to be careful to maintain the invariant. Usually no new results are pushed before checking for trap-conditions. However
align_atomic_addrpopped then re-pushed a value on the value stack before a trap check; this could cause the invariant to be violated and hence lead to a panic.This PR instead uses the
peek1helper to maintain the shape stack entry.Fixes #12808.