[BUG] Segfault when all runs of a Complexity() benchmark are skipped

Aperta Adatta ai principianti
#2,364 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@nitanshnagpal ci sta già lavorando.

Dal 4/11/2026.

  • #2365 di @nitanshnagpal — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp

Direzione di ricerca

Inizia da BenchmarkRunner::DoOneRepetition e RunBenchmarks, menzionati nella spiegazione dell’issue relativa al crash con Runs vuoto. Riproduci il problema con il programma fornito usando Complexity() ed esecuzioni saltate, quindi esamina i test dei benchmark per trovare il punto giusto in cui aggiungere il caso di regressione. Il lavoro è concluso quando tutte le esecuzioni saltate vengono segnalate, i benchmark successivi continuano a essere eseguiti e non compaiono righe BigO o RMS.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug
If every run of a benchmark family using Complexity() is skipped, with either SkipWithMessage or SkipWithError, RunSpecifiedBenchmarks() segfaults. The remaining results are lost, and any later benchmarks don't run. The same benchmark without Complexity() exits normally.

System
- OS: macOS 26.6.2 (arm64)
- Compiler and version: Apple clang 21.0.0 (clang-2100.3.34.2)

To reproduce

  1. Sync to commit e508a65 (main) and build in Release mode.
  2. Compile and run this program, linked against the library:
#include <benchmark/benchmark.h>

static void BM_Sort(benchmark::State& state) {
  state.SkipWithMessage("not supported on this machine");
  for (auto _ : state) {
  }
  state.SetComplexityN(state.range(0));
}
BENCHMARK(BM_Sort)->Range(8, 64)->Complexity();

BENCHMARK_MAIN();
  1. It prints the BM_Sort/8 row, then exits with a segfault (exit code 139) before printing BM_Sort/64.

Expected behavior
Both runs are reported as skipped, no BigO or RMS rows are printed, and the program exits normally.

Additional context
BenchmarkRunner::DoOneRepetition counts skipped runs in num_runs_done, but only adds non-skipped runs to Runs. When every run in a family is skipped, Runs is empty once the family finishes, and RunBenchmarks still calls reports_for_family->Runs.front().family_index. UBSan reports a reference binding to a null pointer there.

The same code is in v1.10.0, though I only ran the reproducer on main.

I'd like to work on this. I have a fix that takes the family index from the benchmark instance, plus a regression test, and can open a PR.

Lingua principale
C++
Stelle
10.5k
Fork
1.8k
Merge medio
2g 2h
PR unite (30g)
31

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di google/benchmark

Tutte le issue di google/benchmark

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.