Skip to content

Fix atomic RMW8/16/32 alignment checks using wrong max alignment#577

Merged
titzer merged 2 commits intotitzer:masterfrom
sumleo:fix/atomic-rmw-alignment-values
Mar 4, 2026
Merged

Fix atomic RMW8/16/32 alignment checks using wrong max alignment#577
titzer merged 2 commits intotitzer:masterfrom
sumleo:fix/atomic-rmw-alignment-values

Conversation

@sumleo
Copy link
Contributor

@sumleo sumleo commented Feb 25, 2026

Summary

  • Atomic RMW sub-word operations (SUB, AND, XCHG variants) have incorrect maximum alignment values in the validator due to copy-paste from the full-width RMW entries, causing over-aligned atomic accesses to be incorrectly accepted.

Details

CodeValidator.v3:1169-1201 — 15 entries affected:

  • RMW8 ops had max_align=4 (i32) or 8 (i64) instead of 1
  • RMW16 ops had max_align=4 (i32) or 8 (i64) instead of 2
  • RMW32 ops had max_align=8 instead of 4

The ADD, OR, XOR, and CMPXCHG groups already had correct values. Only SUB, AND, and XCHG were affected.

Atomic RMW sub-word operations (SUB, AND, XCHG variants) have
incorrect maximum alignment values due to copy-paste from the
full-width RMW entries:
- RMW8 ops used 4 (i32) or 8 (i64) instead of 1
- RMW16 ops used 4 (i32) or 8 (i64) instead of 2
- RMW32 ops used 8 instead of 4

This causes the validator to accept over-aligned atomic accesses that
should be rejected. Fix all 15 affected entries to match the correct
sub-word alignment (consistent with ADD, OR, XOR, and CMPXCHG which
were already correct).
Copy link
Owner

@titzer titzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, can you please add regression tests for these?

Verify that i32.atomic.rmw8.sub_u with over-aligned memarg (align=2)
is correctly rejected. RMW8 operations must have max alignment of 1.
@titzer titzer marked this pull request as draft March 4, 2026 15:40
@titzer titzer marked this pull request as ready for review March 4, 2026 15:40
@titzer titzer merged commit 7b00fcf into titzer:master Mar 4, 2026
9 of 36 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.

2 participants