Using BENCHMARK() on Windows 10 system causes SIGSEGV depending on compiler
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- cmake, cpp
- Ambito
- performance, testing
Direzione di ricerca
Inizia riproducendo il fallimento con main.cpp, Benchmark.cpp e CMakeLists.txt nelle due versioni di MSVC indicate, utilizzando i comandi CMake forniti. Confronta il percorso BENCHMARK() con il risultato del compilatore funzionante e verifica che l’eseguibile termini senza SIGSEGV, mentre REQUIRE() rimane invariato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C++
- Stelle
- 21.6k
- Fork
- 3.4k
- Merge medio
- 3g 12h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di catchorg/Catch2
-
catch_discover_tests fails for Windows test executables run under Wine since v3.15.2Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 2 giorni
-
catch_discover_tests passes all EXTRA_ARGS as one argumentForse già presa @CyberKun l’ha presa 11 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
catchorg/Catch2#3239 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Not seeing some error messages from fakeit in jetbrains riderForse già presa @Amanpal9 l’ha presa 21 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
catchorg/Catch2#3228 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
catch_discover_tests fails for Emscripten/WASM tests since v3.16.0Forse già presa @nafiurahman00 l’ha presa 8 giorni fa. ApertaExtras
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
catchorg/Catch2#3241 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di catchorg/Catch2
Issue simili
-
Build fails on macOS 27: dyld refuses stripped Rust proc-macros (mis-aligned LINKEDIT string pool)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
cloudflare/workerd#8963 ·
I maintainer di solito rispondono entro 1 giorno
-
Android Bug Core Drape
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
organicmaps/organicmaps#14449 ·
I maintainer di solito rispondono entro 1 giorno
-
comp-codecs
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
ClickHouse/ClickHouse#135159 ·
I maintainer di solito rispondono entro 1 giorno
-
difficulty:easy func:python os:windows prio:high type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NatronGitHub/Natron#2029 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
ardazishvili/Sota#114 ·
I maintainer di solito rispondono entro 1 giorno