benchmark icon indicating copy to clipboard operation
benchmark copied to clipboard

[BUG] Segfault in mutex.h

Open benjaminmordaunt opened this issue 2 years ago • 3 comments

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

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.

benjaminmordaunt avatar Sep 28 '23 16:09 benjaminmordaunt

Can not reproduce. There must be something weird going on. Can you please try building benchmark from git manually, does the issue manifest then too?

LebedevRI avatar Sep 28 '23 17:09 LebedevRI

Hi, this seems to have something to do with static linkage, as without -static in target_link_libraries, this issue does not present.

benjaminmordaunt avatar Sep 28 '23 17:09 benjaminmordaunt

Unfortunately that did not help, still does not reproduce for me.

LebedevRI avatar Sep 28 '23 17:09 LebedevRI