jll63 / yomm2

Fast, orthogonal, open multi-methods. Solve the Expression Problem in C++17.
Boost Software License 1.0
348 stars 18 forks source link

Segfault during benchmark [v1.1.2] #23

Closed ph4n70m-nuk3r closed 3 years ago

ph4n70m-nuk3r commented 3 years ago

Hi there, I cloned v1.1.2 today and got a segfault while running the benchmarks. Below are the shell commands and output which was used; if there's anything else I can provide then please let me know, thanks.

Setup:

$ cd /tmp
$ git clone --branch v1.1.2 https://github.com/jll63/yomm2
$ cd yomm2
$ git switch -c v1.1.2
$ mkdir build && cd build

Generate:

$ cmake .. -DYOMM2_ENABLE_TESTS=1 -DYOMM2_ENABLE_BENCHMARKS=1 -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using Boost libraries from /usr/include
-- Tests enabled
-- Benchmarks enabled
-- Package "benchmark" not found in system.
-- Downloading dependency "benchmark" and building from source.
Scanning dependencies of target benchmark
[ 12%] Creating directories for 'benchmark'
[ 25%] Performing download step (git clone) for 'benchmark'
Cloning into 'benchmark'...
remote: Enumerating objects: 3, done.        
remote: Counting objects: 100% (3/3), done.        
remote: Compressing objects: 100% (3/3), done.        
remote: Total 5757 (delta 0), reused 0 (delta 0), pack-reused 5754        
Receiving objects: 100% (5757/5757), 1.83 MiB | 2.94 MiB/s, done.
Resolving deltas: 100% (3771/3771), done.
Already on 'master'
Your branch is up-to-date with 'origin/master'.
[ 37%] No patch step for 'benchmark'
[ 50%] Performing update step for 'benchmark'
Current branch master is up to date.
[ 62%] Performing configure step for 'benchmark'
-- The CXX compiler identification is GNU 9.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Failed to find LLVM FileCheck
-- Found Git: /usr/bin/git (found version "2.25.1") 
-- git Version: v1.5.2-ea5a5bbf
-- Version: 1.5.2
-- Performing Test HAVE_CXX_FLAG_STD_CXX11
-- Performing Test HAVE_CXX_FLAG_STD_CXX11 - Success
-- Performing Test HAVE_CXX_FLAG_WALL
-- Performing Test HAVE_CXX_FLAG_WALL - Success
-- Performing Test HAVE_CXX_FLAG_WEXTRA
-- Performing Test HAVE_CXX_FLAG_WEXTRA - Success
-- Performing Test HAVE_CXX_FLAG_WSHADOW
-- Performing Test HAVE_CXX_FLAG_WSHADOW - Success
-- Performing Test HAVE_CXX_FLAG_WERROR
-- Performing Test HAVE_CXX_FLAG_WERROR - Success
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 - Failed
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS - Success
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED - Success
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WD654
-- Performing Test HAVE_CXX_FLAG_WD654 - Failed
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY - Failed
-- Performing Test HAVE_CXX_FLAG_COVERAGE
-- Performing Test HAVE_CXX_FLAG_COVERAGE - Success
-- Performing Test HAVE_STD_REGEX
-- Performing Test HAVE_STD_REGEX
-- Performing Test HAVE_STD_REGEX -- success
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/yomm2/build/benchmark_build
[ 75%] Performing build step for 'benchmark'
Scanning dependencies of target benchmark
[  4%] Building CXX object src/CMakeFiles/benchmark.dir/benchmark.cc.o
[  9%] Building CXX object src/CMakeFiles/benchmark.dir/benchmark_api_internal.cc.o
[ 14%] Building CXX object src/CMakeFiles/benchmark.dir/benchmark_name.cc.o
[ 19%] Building CXX object src/CMakeFiles/benchmark.dir/benchmark_register.cc.o
[ 23%] Building CXX object src/CMakeFiles/benchmark.dir/benchmark_runner.cc.o
[ 28%] Building CXX object src/CMakeFiles/benchmark.dir/colorprint.cc.o
[ 33%] Building CXX object src/CMakeFiles/benchmark.dir/commandlineflags.cc.o
[ 38%] Building CXX object src/CMakeFiles/benchmark.dir/complexity.cc.o
[ 42%] Building CXX object src/CMakeFiles/benchmark.dir/console_reporter.cc.o
[ 47%] Building CXX object src/CMakeFiles/benchmark.dir/counter.cc.o
[ 52%] Building CXX object src/CMakeFiles/benchmark.dir/csv_reporter.cc.o
[ 57%] Building CXX object src/CMakeFiles/benchmark.dir/json_reporter.cc.o
[ 61%] Building CXX object src/CMakeFiles/benchmark.dir/reporter.cc.o
[ 66%] Building CXX object src/CMakeFiles/benchmark.dir/sleep.cc.o
[ 71%] Building CXX object src/CMakeFiles/benchmark.dir/statistics.cc.o
[ 76%] Building CXX object src/CMakeFiles/benchmark.dir/string_util.cc.o
[ 80%] Building CXX object src/CMakeFiles/benchmark.dir/sysinfo.cc.o
[ 85%] Building CXX object src/CMakeFiles/benchmark.dir/timers.cc.o
[ 90%] Linking CXX static library libbenchmark.a
[ 90%] Built target benchmark
Scanning dependencies of target benchmark_main
[ 95%] Building CXX object src/CMakeFiles/benchmark_main.dir/benchmark_main.cc.o
[100%] Linking CXX static library libbenchmark_main.a
[100%] Built target benchmark_main
[ 87%] Performing install step for 'benchmark'
[ 90%] Built target benchmark
[100%] Built target benchmark_main
Install the project...
-- Install configuration: "Release"
-- Installing: /tmp/yomm2/dependencies/benchmark/lib/libbenchmark.a
-- Installing: /tmp/yomm2/dependencies/benchmark/lib/libbenchmark_main.a
-- Installing: /tmp/yomm2/dependencies/benchmark/lib/cmake/benchmark/benchmarkConfig.cmake
-- Installing: /tmp/yomm2/dependencies/benchmark/lib/cmake/benchmark/benchmarkConfigVersion.cmake
-- Installing: /tmp/yomm2/dependencies/benchmark/lib/pkgconfig/benchmark.pc
-- Installing: /tmp/yomm2/dependencies/benchmark/lib/cmake/benchmark/benchmarkTargets.cmake
-- Installing: /tmp/yomm2/dependencies/benchmark/lib/cmake/benchmark/benchmarkTargets-release.cmake
[100%] Completed 'benchmark'
[100%] Built target benchmark
-- Examples enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/yomm2/build

Build:

$ make
Scanning dependencies of target yomm2
[  2%] Building CXX object src/CMakeFiles/yomm2.dir/yomm2.cpp.o
[  5%] Linking CXX static library libyomm2.a
[  5%] Built target yomm2
Scanning dependencies of target benchmarks
[  8%] Building CXX object tests/CMakeFiles/benchmarks.dir/benchmarks.cpp.o
[ 10%] Building CXX object tests/CMakeFiles/benchmarks.dir/benchmarks_vfuncs.cpp.o
[ 13%] Linking CXX executable benchmarks
[ 13%] Built target benchmarks
Scanning dependencies of target namespaces
[ 16%] Building CXX object tests/CMakeFiles/namespaces.dir/namespaces.cpp.o
[ 18%] Linking CXX executable namespaces
[ 18%] Built target namespaces
Scanning dependencies of target lab
[ 21%] Building CXX object tests/CMakeFiles/lab.dir/lab.cpp.o
[ 24%] Linking CXX executable lab
[ 24%] Built target lab
Scanning dependencies of target blackbox
[ 27%] Building CXX object tests/CMakeFiles/blackbox.dir/blackbox.cpp.o
[ 29%] Linking CXX executable blackbox
[ 29%] Built target blackbox
Scanning dependencies of target whitebox
[ 32%] Building CXX object tests/CMakeFiles/whitebox.dir/whitebox.cpp.o
[ 35%] Linking CXX executable whitebox
[ 35%] Built target whitebox
Scanning dependencies of target synopsis
[ 37%] Building CXX object examples/CMakeFiles/synopsis.dir/synopsis.cpp.o
[ 40%] Linking CXX executable synopsis
[ 40%] Built target synopsis
Scanning dependencies of target matrix
[ 43%] Building CXX object examples/CMakeFiles/matrix.dir/matrix.cpp.o
[ 45%] Linking CXX executable matrix
[ 45%] Built target matrix
Scanning dependencies of target next
[ 48%] Building CXX object examples/CMakeFiles/next.dir/next.cpp.o
[ 51%] Linking CXX executable next
[ 51%] Built target next
Scanning dependencies of target asteroids
[ 54%] Building CXX object examples/CMakeFiles/asteroids.dir/asteroids.cpp.o
[ 56%] Linking CXX executable asteroids
[ 56%] Built target asteroids
Scanning dependencies of target accept_no_visitors
[ 59%] Building CXX object examples/CMakeFiles/accept_no_visitors.dir/accept_no_visitors.cpp.o
[ 62%] Linking CXX executable accept_no_visitors
[ 62%] Built target accept_no_visitors
Scanning dependencies of target adventure
[ 64%] Building CXX object examples/CMakeFiles/adventure.dir/adventure.cpp.o
[ 67%] Linking CXX executable adventure
[ 67%] Built target adventure
Scanning dependencies of target dl_shared
[ 70%] Building CXX object examples/CMakeFiles/dl_shared.dir/dl_shared.cpp.o
[ 72%] Linking CXX shared library libdl_shared.so
[ 72%] Built target dl_shared
Scanning dependencies of target dl_main
[ 75%] Building CXX object examples/CMakeFiles/dl_main.dir/dl_main.cpp.o
[ 78%] Linking CXX executable dl_main
[ 78%] Built target dl_main
Scanning dependencies of target containers
[ 81%] Building CXX object examples/containers/CMakeFiles/containers.dir/main.cpp.o
[ 83%] Building CXX object examples/containers/CMakeFiles/containers.dir/shape_painter.cpp.o
[ 86%] Building CXX object examples/containers/CMakeFiles/containers.dir/concrete_shape_painters.cpp.o
[ 89%] Building CXX object examples/containers/CMakeFiles/containers.dir/line_painter.cpp.o
[ 91%] Building CXX object examples/containers/CMakeFiles/containers.dir/arc_painter.cpp.o
[ 94%] Building CXX object examples/containers/CMakeFiles/containers.dir/segment_painter.cpp.o
[ 97%] Building CXX object examples/containers/CMakeFiles/containers.dir/painter.cpp.o
[100%] Linking CXX executable containers
[100%] Built target containers

Test:

$ ctest
Test project /tmp/yomm2/build
      Start  1: whitebox
 1/11 Test  #1: whitebox .........................   Passed    0.00 sec
      Start  2: blackbox
 2/11 Test  #2: blackbox .........................   Passed    0.00 sec
      Start  3: lab
 3/11 Test  #3: lab ..............................   Passed    0.00 sec
      Start  4: namespaces
 4/11 Test  #4: namespaces .......................   Passed    0.00 sec
      Start  5: synopsis
 5/11 Test  #5: synopsis .........................   Passed    0.00 sec
      Start  6: matrix
 6/11 Test  #6: matrix ...........................   Passed    0.00 sec
      Start  7: accept_no_visitors
 7/11 Test  #7: accept_no_visitors ...............   Passed    0.00 sec
      Start  8: adventure
 8/11 Test  #8: adventure ........................   Passed    0.00 sec
      Start  9: next
 9/11 Test  #9: next .............................   Passed    0.00 sec
      Start 10: asteroids
10/11 Test #10: asteroids ........................   Passed    0.00 sec
      Start 11: containers
11/11 Test #11: containers .......................   Passed    0.00 sec

100% tests passed, 0 tests failed out of 11

Total Test time (real) =   0.03 sec

Benchmark:

$ tests/benchmarks 
2021-02-13T12:16:31+00:00
Running tests/benchmarks
Run on (8 X 4000 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x4)
  L1 Instruction 32 KiB (x4)
  L2 Unified 256 KiB (x4)
  L3 Unified 8192 KiB (x1)
Load Average: 1.88, 1.68, 1.47
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
----------------------------------------------------------------------------------
Benchmark                                        Time             CPU   Iterations
----------------------------------------------------------------------------------
virtual function call                         2.21 ns         2.19 ns    309250625
uni-method call                               2.89 ns         2.86 ns    233315301
double dispatch                               2.47 ns         2.47 ns    280235599
multi-method call                             3.01 ns         3.01 ns    227033837
virtual function call                         2.00 ns         2.00 ns    342081472
uni-method call (virtual inheritance)         2.06 ns         2.06 ns    332755492
double dispatch(virtual inheritance)          2.25 ns         2.25 ns    300920778
multi-method call (virtual inheritance)       3.15 ns         3.15 ns    225812327
virtual function call (hash info in gv)       1.81 ns         1.81 ns    373747104
**Segmentation fault (core dumped)**
jll63 commented 3 years ago

Sorry I missed this. I will look in to it. Thanks for the report.

jll63 commented 3 years ago

OK, interesting. I could not reproduce with g++6, g++8, and clang++6. So I finally spent the effort on upgrading my WSL Ubuntu from 18.04 to 20.04. And, yes, I can reproduce with g++9. I will not look into this further...

jll63 commented 3 years ago

This affects only the experimental policy that replicates the hash function information before each method info in the global vector. Since this policy was never documented, no impact on users.

Fixed in https://github.com/jll63/yomm2/commit/17c0d4fafb2518f2fa9280a65f43b2650cb717d7