Skip to content

Handle ref before expected in Heap2Local for StructCmpxchg#8566

Merged
tlively merged 1 commit intomainfrom
8563
Apr 1, 2026
Merged

Handle ref before expected in Heap2Local for StructCmpxchg#8566
tlively merged 1 commit intomainfrom
8563

Conversation

@tlively
Copy link
Copy Markdown
Member

@tlively tlively commented Apr 1, 2026

When the same optimized allocation flows into both the ref and expected fields of a StructCmpxchg, we previously (arbitrarily) prioritized optimizing based on the flow through expected. But this optimization stores the ref in a scratch local and then creates a new struct.get of its value. Since the same optimized allocation is also flowing through the ref field, that means we end up trying to do a struct.get on a null, which traps. To fix the problem, prioritize doing the optimization based on the flow through ref instead. This drops the other expressions and does not introduce any new accesses of the optimized value.

Fixes #8563.

When the same optimized allocation flows into both the `ref` and `expected` fields of a StructCmpxchg, we previously (arbitrarily) prioritized optimizing based on the flow through `expected`. But this optimization stores the `ref` in a scratch local and then creates a new struct.get of its value. Since the same optimized allocation is also flowing through the `ref` field, that means we end up trying to do a struct.get on a null, which traps. To fix the problem, prioritize doing the optimization based on the flow through `ref` instead. This drops the other expressions and does not introduce any new accesses of the optimized value.

Fixes #8563.
@tlively tlively requested a review from a team as a code owner April 1, 2026 21:00
@tlively tlively requested review from aheejin and kripken and removed request for a team April 1, 2026 21:00
@tlively tlively enabled auto-merge (squash) April 1, 2026 21:33
@tlively tlively merged commit 88a07e0 into main Apr 1, 2026
16 checks passed
@tlively tlively deleted the 8563 branch April 1, 2026 21:34
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.

Heap2Local fuzz bug on struct.atomic.rmw.cmpxchg

2 participants