Using BENCHMARK() on Windows 10 system causes SIGSEGV depending on compiler
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cmake, cpp
- Domain
- performance, testing
Research direction
Start by reproducing the failure with main.cpp, Benchmark.cpp, and CMakeLists.txt under the two listed MSVC versions, using the provided CMake commands. Compare the BENCHMARK() path with the working compiler result and verify that the executable completes without SIGSEGV while REQUIRE() remains unaffected.
Written by the indexing model from the issue text.
Description
Describe the bug
Calling application that uses BENCHMARK() compiled with current MSVC compiler causes program to fail with SIGSEGV on a Windows 10 system. Using an older compiler works.
Expected behavior
When .exe file is called, the benchmark should complete without aborting.
Reproduction steps
Complete minimum viable example:
main.cpp:
#include <catch2/catch_session.hpp>
int main(int argc,char* argv[])
{
return Catch::Session().run(argc, argv);
}
Benchmark.cpp:
#include <catch2/catch_test_macros.hpp>
#include <catch2/benchmark/catch_benchmark.hpp>
int stub()
{
return 0;
}
TEST_CASE("Main") {
BENCHMARK("main") {
return stub();
};
}
CMakeLists.txt:
cmake_minimum_required (VERSION 3.20)
project ("Benchmark" LANGUAGES CXX)
find_package(Catch2 3 REQUIRED)
include(CTest)
include(Catch)
set(benchmark_src "Benchmark.cpp" "main.cpp")
add_executable(benchmark ${benchmark_src})
target_link_libraries(benchmark PRIVATE Catch2::Catch2)
set_property(TARGET benchmark PROPERTY CXX_STANDARD 20)
catch_discover_tests(benchmark)
Code generation for version with bug, started from Development PowerShell for VS 2022:
cmake -DCMAKE_PREFIX_PATH=[...]\Catch2Release -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build .\build\
Code generation for version without bug, started from clean command prompt:
"[...]\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=14.29
cmake -DCMAKE_PREFIX_PATH=[...]\Catch2ReleaseOldCompiler -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build .\build\
Output:
-------------------------------------------------------------------------------
Main
-------------------------------------------------------------------------------
[...]\Benchmark.cpp(9)
...............................................................................
benchmark name samples iterations est run time
mean low mean high mean
std dev low std dev high std dev
-------------------------------------------------------------------------------
main 100 45739 0 ns
[...]\Benchmark.cpp(9[...]\Benchmark.cpp[...]\Benchmark.cpp)(: 9()9: )FAILEDFAILED:
:
: due to a fatal error conditiondue to a fatal error condition:FAILED:
:
due to a fatal error condition SIGSEGV - Segmentation violation signal: SIGSEGV - Segmentation violation signal
===============================================================================
SIGSEGV - Segmentation violation signal===============================================================================
------
---test cases-: -
1- | test cases-1----: --2failed---- |
-2assertions---- : -failed---3--
-assertions- | -: ---3 3-- | -failed3-----
failed
--
-
----------------------------
Platform information:
Target system:
- OS: Microsoft Windows 10 Enterprise LTSC, Version 10.0.17763 Build 17763
General build configuration:
- OS: Windows 11 Pro, Version 10.0.22.631 Build 22631
- Catch version: v3.8.1 devel version at commit 04cbcfa1 (11.06.2025)**
- CMake version: 4.0.3
Build configuration with bug:
- Compiler+version: MSVC 19.44.35211.0 (current version for Visual Studio 2022 as of right now)
Build system configuration without bug:
- Compiler+version: MSVC 19.29.30159.0 (last version for Visual Studio 2019)
Additional context
- I built the Catch2 libraries from the source files with the compiler versions listed above.
- Both versions run on the build system.
- Using other Catch2 features such as REQUIRE() instead of BENCHMARK() does not produce any errors.
- Dominant language
- C++
- Stars
- 21.6k
- Forks
- 3.4k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from catchorg/Catch2
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 2 days
-
catch_discover_tests passes all EXTRA_ARGS as one argumentPossibly taken @CyberKun claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
catchorg/Catch2#3239 · 1 comment ·
Maintainers usually reply within 2 days
-
Not seeing some error messages from fakeit in jetbrains riderPossibly taken @Amanpal9 claimed this 21 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
catchorg/Catch2#3228 · 1 comment ·
Maintainers usually reply within 2 days
-
catch_discover_tests fails for Emscripten/WASM tests since v3.16.0Possibly taken @nafiurahman00 claimed this 8 days ago. OpenExtras
Difficulty 3/5 1-2 days Newbie friendliness 72/100
catchorg/Catch2#3241 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cp-algorithms/cp-algorithms#1774 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
telefonicaid/fiware-orion#4836 ·
Maintainers usually reply within 1 day
-
nixd exits at startup when its parent process belongs to another userPossibly taken @conao3 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nix-community/nixd#930 ·
Maintainers usually reply within 2 days
-
refactor topic-ui topic-weather
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Command-Install Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
microsoft/winget-cli#6718 ·
Maintainers usually reply within 2 days