diff options
| author | Alan Jowett | 2021-12-15 09:51:04 -0700 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-01-03 22:50:32 +0100 |
| commit | 98a6c69e1e429a86140301dfa5563b1d7263e813 (patch) | |
| tree | b42e769a5151387098628f37d1739ac05047436c /tests | |
| parent | d3199c42c2af0f69e43686c2b47189c8bad04026 (diff) | |
| download | catch3-98a6c69e1e429a86140301dfa5563b1d7263e813.tar.gz | |
Switch from AddVectoredExceptionHandler to SetUnhandledExceptionFilter
This avoids issues with Catch2's handler firing too early, on
structured exceptions that would be handled later. This issue
meant that the old attempts at structured exception handling
were incompatible with Windows's ASan, because it throws
continuable `C0000005` exception, which it then handles.
With the new handling, Catch2 is only notified if nothing else,
including the debugger, has handled the exception.
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Closes #2332
Closes #2286
Closes #898
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/SelfTest/UsageTests/Misc.tests.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/Misc.tests.cpp b/tests/SelfTest/UsageTests/Misc.tests.cpp index 2d40a6b1..e5409772 100644 --- a/tests/SelfTest/UsageTests/Misc.tests.cpp +++ b/tests/SelfTest/UsageTests/Misc.tests.cpp @@ -6,6 +6,7 @@ #include <catch2/catch_test_macros.hpp> #include <catch2/catch_template_test_macros.hpp> #include <catch2/internal/catch_config_wchar.hpp> +#include <catch2/internal/catch_windows_h_proxy.hpp> #ifdef __clang__ # pragma clang diagnostic ignored "-Wc++98-compat" @@ -498,3 +499,34 @@ TEMPLATE_TEST_CASE_SIG("#1954 - 7 arg template test case sig compiles", "[regres TEST_CASE("Same test name but with different tags is fine", "[.approvals][some-tag]") {} TEST_CASE("Same test name but with different tags is fine", "[.approvals][other-tag]") {} + +#if defined(CATCH_PLATFORM_WINDOWS) +void throw_and_catch() +{ + __try { + RaiseException(0xC0000005, 0, 0, NULL); + } + __except (1) + { + + } +} + + +TEST_CASE("Validate SEH behavior - handled", "[approvals][FatalConditionHandler][CATCH_PLATFORM_WINDOWS]") +{ + // Validate that Catch2 framework correctly handles tests raising and handling SEH exceptions. + throw_and_catch(); +} + +void throw_no_catch() +{ + RaiseException(0xC0000005, 0, 0, NULL); +} + +TEST_CASE("Validate SEH behavior - unhandled", "[.approvals][FatalConditionHandler][CATCH_PLATFORM_WINDOWS]") +{ + // Validate that Catch2 framework correctly handles tests raising and not handling SEH exceptions. + throw_no_catch(); +} +#endif |