Relational comparison of a negative BigInt with a negative fraction ignores the sign when exponents differ

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

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

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

評価

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

調査の方向性

quickjs.c の js_bigint_float64_cmp から始め、特に 13588~13593 行付近の f != e 分岐を確認します。符号の扱いを仮数部の分岐と比較し、報告された -14n < -7.25 のケースで IsLessThan の動作を確認します。このケースで比較結果が true となり、既存の BigInt と Number の関係比較が引き続き正しく動作すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Comparing a negative BigInt with a negative fractional Number returns the inverted result when the binary exponents differ.

console.log(-14n < -7.25);

Expected: true
Actual (observed): false

Spec: IsLessThan.
Version: quickjs-ng master, revision not recorded in the test build (source read at a36054a). Built with the quickjs-ng on our build host.

Fix note: js_bigint_float64_cmp (quickjs.c:13552), the f != e branch (13588-13593), returns from the exponents alone without the a_sign flip that the mantissa branch applies. Use if (f < e) return 2*a_sign-1; else return 1-2*a_sign;.

We found this while fuzzing.

Credit: https://ucsbplse.github.io/

主要言語
C
スター
3.9k
フォーク
389
平均マージ
2日 2時間
マージ済み PR(30日)
21

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

quickjs-ng/quickjs のほかの issue

quickjs-ng/quickjs の issue をすべて見る

似ている issue

C の issue をもっと見る

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

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