Cranelift: interpreter: incorrect edge-case handling in fcvt_to_{u,s}int.i128
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
floatからi128への変換付近にある cranelift/interpreter/src/step.rs と、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時間
- マージ済み PR(30日)
- 380
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
bytecodealliance/wasmtime#15195 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 20/100
bytecodealliance/wasmtime#15193 ·
メンテナーはふだん 1 日以内に返信
-
awfy performance
難易度 4/5 3〜5日 初心者へのやさしさ 44/100
bytecodealliance/wasmtime#15192 ·
メンテナーはふだん 1 日以内に返信
bytecodealliance/wasmtime の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
RustCrypto/utils#1597 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
max-sixty/worktrunk#4727 · コメント 7 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
follow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
carrick-sh/carrick#1859 ·
メンテナーはふだん 1 日以内に返信