Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix ComputeStats crash when first repetition is skipped#2207

Closed
dforsten wants to merge 2 commits into
google:mainfrom
vizrt:dfo/linux-statistics-crash-fix
Closed

Fix ComputeStats crash when first repetition is skipped#2207
dforsten wants to merge 2 commits into
google:mainfrom
vizrt:dfo/linux-statistics-crash-fix

Conversation

@dforsten

Copy link
Copy Markdown

Fixes #2206

When --benchmark_repetitions > 1 and the first repetition is skipped (via SkipWithError / SkipWithMessage ), ComputeStats() crashes due to:

  1. Dereferencing null reports[0].statistics (only set for non-skipped runs).
  2. Expecting reports.front().iterations to match every non-skipped run's iteration count.

Fixed by:

  • Picking the first non-skipped report as the baseline for run_iterations , report_label , and statistics.
  • Ensuring report.statistics is always initialized in CreateRunReport() , even for skipped runs.
  • Skipping skipped runs in aggregation and consistency loops.

Also adds a regression test reproducing the crash.

AI-Assisted-by: Gemini (Google DeepMind Antigravity)

@google-cla

google-cla Bot commented May 26, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@dforsten

dforsten commented May 26, 2026

Copy link
Copy Markdown
Author

The issue was encountered on a project using the vcpkg "benchmark" port version 1.9.5.
We worked around it by creating an overlay port and applying patches with the same fixes as in this PR.

That works for now, but it would be great to get it fixed upstream and eventually published to the vcpkg registry so we can eliminate that overlay port.

@LebedevRI

Copy link
Copy Markdown
Collaborator

Please rebase now that #2199 has been merged.
Why do we need to always have valid statistics pointer even for skipped runs?

@dforsten

Copy link
Copy Markdown
Author

Why do we need to always have valid statistics pointer even for skipped runs?

That was the initial fix for the crash I encountered, but further investigation led to fixing the issues in statistics.cc which avoided both the crash and produces correct results.

In principle the change in benchmark_runner.cc could be reverted, but on the other hand it makes the code more robust since the pointer is always valid.

@LebedevRI LebedevRI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Awaiting diff update)

dforsten added 2 commits May 26, 2026 21:05
Adds a test verifying that calling SkipWithError on the first repetition with --benchmark_repetitions > 1 does not crash ComputeStats.

AI-Assisted-by: Gemini (Google DeepMind Antigravity)
Fixes a crash in ComputeStats() when the first repetition is skipped by picking the first non-skipped report as the baseline for iterations and statistics, and ensuring report.statistics is always initialized.

AI-Assisted-by: Gemini (Google DeepMind Antigravity)
@dforsten dforsten force-pushed the dfo/linux-statistics-crash-fix branch from 9e7a49d to 1dd0dcf Compare May 26, 2026 19:07
@dforsten

Copy link
Copy Markdown
Author

Well, it looks like #2199 may actually fixed this crash issue.
I have to test by adapting our vcpkg overlay port to use the latest main branch commit without the patches we applied.

Comment thread src/benchmark_runner.cc
@dforsten dforsten closed this May 26, 2026
@LebedevRI

Copy link
Copy Markdown
Collaborator

@dforsten thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ComputeStats crash when first repetition is skipped

2 participants