Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

UB: (int) cast of a user double outside int range in dispatch / vm_index_is_int / flat_index_at

オープン 初心者向け
#1,748 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c
領域
compilers

調査の方向性

指定された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 の本文から書いたものです。

説明

area:runtime-vm

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 sweep grep -n '(int)' src/*.c over user-double conversions is classified.
  • The repro above is clean under make asan (no runtime error:), and still raises value.
主要言語
C
スター
3
フォーク
7
平均マージ
8時間 44分
マージ済み PR(30日)
252

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

InauguralSystems/EigenScript のほかの issue

InauguralSystems/EigenScript の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。