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

Abierto Apto para principiantes
#2,364 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@nitanshnagpal ya está trabajando en esto.

Desde el 4/11/2026.

  • #2365 de @nitanshnagpal — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
75/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp

Línea de trabajo

Empieza por BenchmarkRunner::DoOneRepetition y RunBenchmarks, mencionados en la explicación del issue sobre el fallo con Runs vacío. Reproduce el fallo con el programa proporcionado usando Complexity() y ejecuciones omitidas. Después, revisa las pruebas de benchmarks para encontrar el lugar adecuado donde añadir el caso de regresión. Se habrá terminado cuando se informen todas las ejecuciones omitidas, se sigan ejecutando los benchmarks posteriores y no aparezcan filas de BigO ni RMS.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C++
Estrellas
10.5k
Forks
1.8k
Merge medio
2 d 2 h
PR fusionados (30 d)
31

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de google/benchmark

Todos los issues de google/benchmark

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.