AvoidReinterprets: `i32.atomic.load` under `f32.reinterpret_i32` loses its atomicity
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #9228 来自 @tamaroning —— 已合并
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- wasm
- 领域
- compilers
调研方向
从 AvoidReinterprets pass 中的 makeReinterpretedLoad 开始,使用提供的 .wat 模块通过 wasm-opt --avoid-reinterprets --print 重现该问题。完成的标准是 i32.atomic.load 不会被重写为非原子 f32.load,同时保留原始的访问行为。
由索引模型根据 Issue 内容生成。
描述
Summary
makeReinterpretedLoad rebuilds the load from bytes/offset/align/ptr/type/memory and does not carry over isAtomic.
Root cause
The rebuilt load copies the listed fields only, so the original load's isAtomic is dropped.
Copying isAtomic is not a fix, because atomic loads exist only for i32 and i64 (the validator rejects other types) and the rebuilt load has type f32. The pass should skip atomic loads.
Affected passes
Only AvoidReinterprets.
Reproducer
(module (memory 1 1)
(func (export "f") (param $p i32) (result f32)
(f32.reinterpret_i32 (i32.atomic.load (local.get $p)))))
$ wasm-opt in.wat -all --avoid-reinterprets --print
(func $0 (type $0) (param $p i32) (result f32)
(f32.load
(local.get $p)
)
)
The i32.atomic.load has become a plain f32.load.
Expected vs actual
An unaligned address that traps for the atomic access no longer traps, and on a shared memory the access is no longer atomic.
Version
Reproduced on upstream main at 4d8ac549e2ab9b283246ea95e79ebe139ca579ac (wasm-opt version 133).
AI was used as part of the process of finding this issue. I have manually checked and reproduced it.
- 主要语言
- WebAssembly
- 星标
- 8.7k
- 派生
- 895
- 平均合并
- 1 天 21 小时
- 30 天内合并 PR
- 95
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
WebAssembly/binaryen 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
WebAssembly/binaryen#9135 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 76/100
WebAssembly/binaryen#9018 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 45/100
WebAssembly/binaryen#9249 ·
维护者通常 1 天内回复
-
OptimizeInstructions: `--tnh` makes `ref.cast` non-nullable before a possibly infinite loop可能已有人在做 @tamaroning 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 45/100
WebAssembly/binaryen#9246 · 2 条评论 ·
维护者通常 1 天内回复
-
Memory64Lowering: table.get/table.set keep i64 index on lowered table64, output fails validation未关闭
难度 3/5 半天 新手友好度 66/100
WebAssembly/binaryen#9245 · 2 条评论 ·
维护者通常 1 天内回复
查看 WebAssembly/binaryen 的全部 Issue
相似的 Issue
-
Invalid model / false unsat: to_fp of real * 2^int with a symbolic rounding mode treats RTN as RTZ未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
KhronosGroup/SPIRV-LLVM-Translator#4082 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
bradcypert/plum#227 ·
维护者通常 1 天内回复
-
crash mlir
难度 2/5 1-3 小时 新手友好度 68/100
llvm/llvm-project#231201 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
parcel-bundler/lightningcss#1370 ·
维护者通常 1 天内回复