google / google/benchmark

[BUG] Segfault in mutex.h

Open
#1,672 3 comments 0 reactions 0 assignees View on GitHub
incomplete
Dominant language
C++
Stars
10.4k
Forks
1.8k
Avg merge
2d 4h
Merged PRs (30d)
8

Description

**Describe the bug**
I'm getting a null dereference within class Barrier for a trivial use-case example.

**System**
Which OS, compiler, and compiler version are you using:
- OS: Linux x86_64 Ubuntu 20.04 LTS
- Compiler and version: All I've tried (GCC 9.0 - 12.3), Clang 12

**To reproduce**

Simple reproducer:

```
void benchmark_no_op(benchmark::State& state) {
for (auto _ : state) {
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}

// Register the benchmarks.
BENCHMARK(benchmark_no_op);

// Run the benchmarks.
BENCHMARK_MAIN();
```

**Expected behavior**
No runtime segmentation fault.

**Screenshots**
![image](https://github.com/google/benchmark/assets/17656637/7cd131ce-9d59-4f70-8e09-3712d9c453dd)

Stack trace:
```
#0 0x0000000000000000 in ?? ()
#1 0x000000000048416d in std::condition_variable::notify_all() ()
#2 0x000000000040923d in wait (this=0x6c4ee0)
#3 0x0000000000409588 in StartStopBarrier (this=0x6c4e10)
#4 0x000000000040a95b in StartKeepRunning (this=0x7fffffffa7f0)
#5 0x00000000004055ae in benchmark_no_op (state=...)
#6 0x000000000042020e in benchmark::internal::FunctionBenchmark::Run (this=0x6b1fe0, st=...)
#7 0x00000000004762e3 in Run (this=0x6c43e0, iters=1, thread_id=0, timer=0x7fffffffa7c0,
#8 0x000000000045454b in RunInThread (b=0x6c43e0, iters=1, thread_id=0, manager=0x6c4e10,
#9 0x000000000045541a in DoNIterations (this=0x6c4d30)
#10 0x0000000000455e6d in DoOneRepetition (this=0x6c4d30)
#11 0x000000000040b6c9 in RunBenchmarks (benchmarks=..., display_reporter=0x6b2110, file_reporter=0x0)
#12 0x000000000040c614 in RunSpecifiedBenchmarks (display_reporter=0x6b2110, file_reporter=0x0,
#13 0x000000000040be13 in RunSpecifiedBenchmarks ()
#14 0x0000000000405700 in main (argc=1, argv=0x7fffffffddb8)
```

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.