UB: (int) cast of a user double outside int range in dispatch / vm_index_is_int / flat_index_at
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
指定された4か所から始めます: src/builtins.c の5946行付近にある builtin_dispatch、src/vm.c の vm_index_is_int、src/builtins_tensor.c の flat_index_at のリスト分岐、そして finite_num_to_byte です。issue にあるディスパッチのスニペットを make asan の下で再現し、UBSan の float-cast-overflow レポートを確認してください。各箇所でキャスト前に double の範囲をチェックしていること(NaN は false になる)、grep -n '(int)' src/*.c の結果を分類済みであること、そして再現で value のエラーが出力され runtime error: の行が一切出ないことが完了条件です。
索引モデルが issue の本文から書いたものです。
説明
Found while building #1746 Phase 1. Several sites convert a user double to int with a bare (int) cast before any range check. For |x| >= 2^31 (today: up to ±1e308; under an IEEE build also inf/NaN) that is undefined behaviour, and UBSan's float-cast-overflow (on in every ASan variant) reports it.
Repro (any asan build):
define g(x) as:
return x
d is dispatch
print of (d of [[g], 1e308, 5])
-> src/builtins.c:5946:20: runtime error: 1e+308 is outside the range of representable values of type 'int' (then the intended dispatch key must be an integer raise).
Sites: builtin_dispatch (builtins.c, (int)eigs_num_arg(key_v, ...)), vm_index_is_int (vm.c), flat_index_at list arm (builtins_tensor.c), finite_num_to_byte ((int)fmod(x,256) with a NaN). The #1746 experiment guards only vm_index_is_int, only under -DEIGS_IEEE.
Done when
- Each listed site range-checks (
!(d >= INT_MIN && d <= INT_MAX)style, NaN-false) before the cast, and the sweepgrep -n '(int)' src/*.cover user-double conversions is classified. - The repro above is clean under
make asan(noruntime error:), and still raisesvalue.
- 主要言語
- C
- スター
- 3
- フォーク
- 7
- 平均マージ
- 8時間 44分
- マージ済み PR(30日)
- 252
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
InauguralSystems/EigenScript のほかの issue
-
area:stdlib found-by:critic kind:gate-defect
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
InauguralSystems/EigenScript#1693 ·
メンテナーはふだん 1 日以内に返信
-
area:gfx bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
InauguralSystems/EigenScript#1684 ·
メンテナーはふだん 1 日以内に返信
-
area:stdlib bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
InauguralSystems/EigenScript#1679 ·
メンテナーはふだん 1 日以内に返信
-
area:consumer
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
InauguralSystems/EigenScript#1658 ·
メンテナーはふだん 1 日以内に返信
-
area:stdlib kind:silent-wrong
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
InauguralSystems/EigenScript#1652 ·
メンテナーはふだん 1 日以内に返信
InauguralSystems/EigenScript の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
foomatic-rip: dstrtrim_right() underflows mid-loop on an all-whitespace string対応中かも @ManasBagul23 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
OpenPrinting/cups-filters#759 ·
メンテナーはふだん 11 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
EchoTools/nevr-runtime#547 ·
メンテナーはふだん 1 日以内に返信