Skip to content

Debugging: fix panic in align_atomic_addr when guest-debug is enabled.#12815

Merged
alexcrichton merged 1 commit intobytecodealliance:mainfrom
cfallin:issue-12808
Mar 21, 2026
Merged

Debugging: fix panic in align_atomic_addr when guest-debug is enabled.#12815
alexcrichton merged 1 commit intobytecodealliance:mainfrom
cfallin:issue-12808

Conversation

@cfallin
Copy link
Member

@cfallin cfallin commented Mar 21, 2026

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 #12808.

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.
@cfallin cfallin requested review from a team as code owners March 21, 2026 00:25
@cfallin cfallin requested review from pchickey and removed request for a team March 21, 2026 00:25
@alexcrichton alexcrichton added this pull request to the merge queue Mar 21, 2026
Merged via the queue into bytecodealliance:main with commit f345ee7 Mar 21, 2026
46 checks passed
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.

An assertion failed with config.guest_debug(true)

2 participants