You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My testing environment is mac osx 10.9.5 with xcode 6 and clang-600.0.5.
Here is the test code (copied from README):
#include"benchmark/benchmark.h"staticvoidBM_StringCreation(benchmark::State& state) {
while (state.KeepRunning())
std::string empty_string;
}
// Register the function as a benchmarkBENCHMARK(BM_StringCreation);
// Define another benchmarkstaticvoidBM_StringCopy(benchmark::State& state) {
std::string x = "hello";
while (state.KeepRunning())
std::string copy(x);
}
BENCHMARK(BM_StringCopy);
intmain(int argc, constchar** argv) {
// BENCHMARK(BM_StringCreation);// BENCHMARK(BM_StringCopy);benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
return0;
}
At the end of the execution for everytime, a crash message shows up:
Reading /proc/self/cputime_ns failed. Using getrusage().
Benchmarking on 4 X 1000 MHz CPUs
2014/10/05-11:41:53
DEBUG: Benchmark Time(ns) CPU(ns) Iterations
---------------------------------------------------------
DEBUG: BM_StringCreation 14 28 18115649
DEBUG: BM_StringCopy 9 23 22298993
libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
Abort trap: 6
When I move BENCHMARK() lines into main(), the issue disappeared.
I debugged this issue for a few hours, and then I realized that the problem is: the static std::mutex benchmark_mutex has been destroyed before static BenchmarkFamilies instance. The destructor of Benchmark calls BenchmarkFamilies::RemoveBenchmark(), but the mutex already invalid, and then it just crashes.
The text was updated successfully, but these errors were encountered:
zjx20
changed the title
Crash due to the uncertain destroy order of static variables
Crash due to the uncertain destroying order of static variables
Oct 5, 2014
zjx20
added a commit
to zjx20/benchmark
that referenced
this issue
Oct 5, 2014
I had encountered a reproducible crash issue.
My testing environment is mac osx 10.9.5 with xcode 6 and clang-600.0.5.
Here is the test code (copied from README):
At the end of the execution for everytime, a crash message shows up:
When I move
BENCHMARK()
lines intomain()
, the issue disappeared.I debugged this issue for a few hours, and then I realized that the problem is: the
static std::mutex benchmark_mutex
has been destroyed beforestatic BenchmarkFamilies instance
. The destructor ofBenchmark
callsBenchmarkFamilies::RemoveBenchmark()
, but the mutex already invalid, and then it just crashes.The text was updated successfully, but these errors were encountered: