Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark dumping core in "RunInThread" Function. #524

Closed
bansalnvn opened this issue Feb 6, 2018 · 5 comments
Closed

benchmark dumping core in "RunInThread" Function. #524

bansalnvn opened this issue Feb 6, 2018 · 5 comments

Comments

@bansalnvn
Copy link

Hi I am trying to run a simplest benchmark on my amd ryzen 7 machine. I am seeing a core dump in RunInThread function.

2018-02-06 12:31:10
Run on (16 X 3000 MHz CPU s)
CPU Caches:
L1 Data 32K (x8)
L1 Instruction 64K (x8)
L2 Unified 512K (x8)
L3 Unified 8192K (x2)

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
uname -a
Linux lt-hkg1-dws13 4.14.5-1.el7.elrepo.x86_64 #1 SMP Sun Dec 10 09:54:56 EST 2017 x86_64 x86_64 x86_64 GNU/Linux

g++ --version
g++ (GCC) 6.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
and the backtrace of the core is

#0 0x0000000000000000 in ?? ()
#1 0x000000000040dc55 in benchmark::internal::(anonymous namespace)::RunInThread(benchmark::internal::Benchmark::Instance const*, unsigned long, int, benchmark::internal::ThreadManager*) ()
#2 0x000000000040ed50 in benchmark::RunSpecifiedBenchmarks(benchmark::BenchmarkReporter*, benchmark::BenchmarkReporter*) ()
#3 0x0000000000405ad0 in main (argc=, argv=0x7fffa795b998) at /home/nbansal/Documents/lt/git/c/lt-jarvis/bench/./include/benchedsreader.h:35

static void BM_test(benchmark::State& state){
    for( auto _ : state) std::string("test");
}
BENCHMARK(BM_test);

BENCHMARK_MAIN();```
@dmah42
Copy link
Member

dmah42 commented Feb 6, 2018 via email

@bansalnvn
Copy link
Author

bansalnvn commented Feb 7, 2018

I can produce it with the sample code given in this page as well.
One more thing I did compile the libbenchmark from the master branch and the last commit is

commit bc83262 (HEAD -> master, origin/master, origin/HEAD)
Author: Tim timothy.joseph.ohearn@gmail.com
Date: Sat Feb 3 23:04:36 2018 -0600
.vs/ and CmakeSettings.json to gitignore (#522)

[nbansal@lt-hkg1-dws13 codes]$ g++ -std=c++17 bench.cpp -lbenchmark
[nbansal@lt-hkg1-dws13 codes]$ ./a.out 
2018-02-07 09:27:47
Run on (16 X 3000 MHz CPU s)
CPU Caches:
  L1 Data 32K (x8)
  L1 Instruction 64K (x8)
  L2 Unified 512K (x8)
  L3 Unified 8192K (x2)
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
Segmentation fault (core dumped)
[nbansal@lt-hkg1-dws13 codes]$ uname -a
Linux lt-hkg1-dws13 4.14.5-1.el7.elrepo.x86_64 #1 SMP Sun Dec 10 09:54:56 EST 2017 x86_64 x86_64 x86_64 GNU/Linux
[nbansal@lt-hkg1-dws13 codes]$ less bench.cpp ^C
[nbansal@lt-hkg1-dws13 codes]$ cat bench.cpp 
#include <benchmark/benchmark.h>

static void BM_StringCreation(benchmark::State& state) {
    for (auto _ : state)
        std::string empty_string;
}
// Register the function as a benchmark
BENCHMARK(BM_StringCreation);

// Define another benchmark
static void BM_StringCopy(benchmark::State& state) {
    std::string x = "hello";
    for (auto _ : state)
        std::string copy(x);
}
BENCHMARK(BM_StringCopy);

BENCHMARK_MAIN();

@dmah42
Copy link
Member

dmah42 commented Feb 7, 2018 via email

@bansalnvn
Copy link
Author

I can see, if I use the default system compiler which is 4.8 then it works fine. But if I use gcc 6.4 which I installed later on, then I see this crash.

For testing it simpally I am not using cmake, just the command line to compile and run.

[nbansal@lt-hkg1-dws13 codes]$ /usr/bin/g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[nbansal@lt-hkg1-dws13 codes]$ /usr/bin/g++ -std=c++11 -O3 bench.cpp -lbenchmark
[nbansal@lt-hkg1-dws13 codes]$ ./a.
bash: ./a.: No such file or directory
[nbansal@lt-hkg1-dws13 codes]$ ./a.out 
2018-02-07 10:51:18
Run on (16 X 3000 MHz CPU s)
CPU Caches:
  L1 Data 32K (x8)
  L1 Instruction 64K (x8)
  L2 Unified 512K (x8)
  L3 Unified 8192K (x2)
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
---------------------------------------------------------
Benchmark                  Time           CPU Iterations
---------------------------------------------------------
BM_StringCreation          0 ns          0 ns 1000000000
BM_StringCopy              5 ns          5 ns  132871934
[nbansal@lt-hkg1-dws13 codes]$ /opt/lt/rel/x86_64-centos7-linux/gcc/6.4.0/bin/g++ -std=c++17 -O3 bench.cpp -lbenchmark
[nbansal@lt-hkg1-dws13 codes]$ ./a.out 
2018-02-07 10:51:27
Run on (16 X 3000 MHz CPU s)
CPU Caches:
  L1 Data 32K (x8)
  L1 Instruction 64K (x8)
  L2 Unified 512K (x8)
  L3 Unified 8192K (x2)
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
Segmentation fault (core dumped)

@bansalnvn
Copy link
Author

Now I have it working. I think it was compiler version mismatch between how I compiled libbenchmark and my benchmark itself.
Now I can see if I am compiling both of them with the same compiler version, everything works. I am closing the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants