[BUG] Segfault when all runs of a Complexity() benchmark are skipped
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 75/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- cpp
- 领域
- performance, testing
调研方向
从 issue 中关于 Runs 为空时崩溃的说明所提到的 BenchmarkRunner::DoOneRepetition 和 RunBenchmarks 开始。使用提供的程序,通过 Complexity() 和跳过的运行来复现问题,然后检查基准测试,找到添加回归用例的合适位置。完成标准是:报告所有跳过的运行,后续基准测试仍会运行,并且不出现 BigO 或 RMS 行。
由索引模型根据 Issue 内容生成。
描述
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
- Sync to commit e508a65 (
main) and build in Release mode. - 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();
- It prints the
BM_Sort/8row, then exits with a segfault (exit code 139) before printingBM_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.
- 主要语言
- C++
- 星标
- 10.5k
- 派生
- 1.8k
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 28
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google/benchmark 的其他 Issue
-
[BUG] Confusing title in docs/platform_specific_build_instructions.md可能已有人在做 @skryabae 于 31 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
[BUG] Memory manager counts allocations not part of benchmark可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
google/benchmark#2149 · 5 条评论 ·
维护者通常 1 天内回复
-
[FR] Add native Zig bindings via top-level `bindings/zig`可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 5/5 一周以上 新手友好度 42/100
google/benchmark#2266 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
google/benchmark#2235 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
google/benchmark#2195 · 3 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
godotengine/godot#125272 ·
维护者通常 1 天内回复
-
bug impact: performance priority: med review: 2026-11 severity: med
难度 2/5 1-3 小时 新手友好度 78/100
mgradwohl/ModernLife#67 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
games-on-whales/wolf#569 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
cloudflare/workerd#8290 ·
维护者通常 1 天内回复