[BUG] Large iteration counts are parsed incorrectly on Windows
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
調査の方向性
src/benchmark_runner.cc の ParseBenchMinTime() から始めます。issue では、Windows でのオーバーフローの原因として std::strtol が挙げられています。既存のサフィックスとエラーの処理を確認し、32 ビットの境界値、より大きなカウント、符号付き 64 ビット整数の最大値、オーバーフローの拒否について記載された回帰テストを確認します。パーサーが期待される 64 ビットのカウントを返し、オーバーフローを拒否すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
On Windows x64, --benchmark_min_time=4294967296x requests
4,294,967,296 iterations, but the Release build parses the count
as 2,147,483,647.
System
- Windows x64
- MSVC 19.44
- Upstream commit: 48ece68f18fff770e873d398d58bd27afe15ea7e
- Release build configured with CMake
To reproduce
Call benchmark::internal::ParseBenchMinTime("4294967296x")
and inspect the returned iters field.
- Expected: 4294967296
- Actual on Windows Release: 2147483647
The reproduction calls the parser directly; it does not execute
billions of benchmark iterations.
Observed output
Input Expected Actual
2147483647x 2147483647 2147483647
2147483648x 2147483648 2147483647
4294967296x 4294967296 2147483647
1000000000000x 1000000000000 2147483647
Cause And Proposed Fix
ParseBenchMinTime() in src/benchmark_runner.cc uses
std::strtol, whose return type is a 32-bit long on Windows,
although IterationCount is 64-bit.
For these larger values, the conversion overflows before the
result is assigned to IterationCount. The existing BM_CHECK
is disabled in Release builds, so the saturated value is returned.
I have prepared a fix using std::strtoll, preserving the existing
suffix and error checks, together with regression tests for the
32-bit boundary, larger counts, the maximum signed 64-bit count,
and overflow rejection.
Would this change be welcome?
Validation
- The new regression fails before the fix and passes afterward.
- All 88 Windows Release CTest tests pass with the fix.
- All three focused Debug min-time tests pass, including overflow checks.
- Linux and Bazel builds have not been tested locally.
AI Disclosure
AI tools assisted with investigating and reproducing this bug,
preparing the proposed fix and tests, running validation, and
drafting this report.
- 主要言語
- C++
- スター
- 10.5k
- フォーク
- 1.8k
- 平均マージ
- 2日 1時間
- マージ済み PR(30日)
- 28
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/benchmark のほかの issue
-
[BUG] Memory manager counts allocations not part of benchmark再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
google/benchmark#2149 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
-
[FR] New "benchstat" output format対応中かも @DenysZm が 4 日前に担当しました。 オープン
google/benchmark#2397 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
google/benchmark#2391 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[FR] Add native Zig bindings via top-level `bindings/zig`再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
google/benchmark#2266 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
google/benchmark#2235 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
google/benchmark の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
component: tabs platform: macOS
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
zen-browser/desktop#16860 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
metasequoiaime/msime#12003 ·
メンテナーはふだん 1 日以内に返信