Cranelift: interpreter: incorrect edge-case handling in fcvt_to_{u,s}int.i128
维护者通常 1 天内回复
评估
调研方向
阅读 cranelift/interpreter/src/step.rs 中 float 到 i128 转换附近的代码,以及 cranelift/codegen/meta/src/shared/instructions.rs 中的指令文档。然后检查 runtests/i128-conversion.clif,并运行相关的 Cranelift 解释器测试。当超出范围的有符号转换触发 trap,且无符号转换对 [2¹²⁷, 2¹²⁸) 范围内的输入返回预期值时,任务即完成。
由索引模型根据 Issue 内容生成。
描述
Minor/pedantic bug. The float-to-int128 conversions in the interpreter misbehave when passed very large (or very negative) values:
- fcvt_to_sint.i128 returns i128::MAX or i128::MIN for out-of-range inputs. The doc comments say it should trap.
- fcvt_to_uint.i128 and fcvt_to_uint_sat.i128 clamp some large inputs (in the interval [2¹²⁷, 2¹²⁸)) to i128::MAX, even though those values should fit in the result.
I noticed this issue because runtests/i128-conversion.clif matches the implementation, so it has three incorrect expectations:
- Line 14:
; run: %fcvt_to_uint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Should return: 340282346638528859811704183484516925440
- The nearly identical call on line 40 should have the same result:
; run: %fcvt_to_uint_sat_i128(0x1.fffffep127) == 170141183460469231731687303715884105727
- Line 28:
; run: %fcvt_to_sint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Should trap
The root cause is that the interpreter's fcvt_to_uint and fcvt_to_sint cast the input with as i128 before the bounds check.
- 主要语言
- Rust
- 星标
- 18.8k
- 派生
- 1.9k
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 357
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bytecodealliance/wasmtime 的其他 Issue
-
bug wasm-proposal:exceptions wasmtime:debugging
难度 2/5 1-3 小时 新手友好度 76/100
bytecodealliance/wasmtime#14102 ·
维护者通常 1 天内回复
-
wasm-proposal:gc
难度 2/5 1-3 小时 新手友好度 62/100
bytecodealliance/wasmtime#13808 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 35/100
bytecodealliance/wasmtime#15203 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
bytecodealliance/wasmtime#15195 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 20/100
bytecodealliance/wasmtime#15193 ·
维护者通常 1 天内回复
查看 bytecodealliance/wasmtime 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 69/100
bytecodealliance/rustix#1736 ·
维护者通常 1 天内回复
-
area:models enhancement
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
good first issue help wanted
难度 1/5 1 小时以内 新手友好度 84/100
servo/rust-smallvec#864 ·
-
bug frontend ui
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复