-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[clang] [windows] [address-sanitizer] stack overflow when test is failing #898
Comments
FWIW this works normally under Linux. What if you use normal Clang:
Also, you seem to be building a normal, shared executable. What if you change the library name to |
Compiling with
gives me ==748==AddressSanitizer CHECK failed: D:\src\llvm_package_300231\llvm\projects\compiler-rt\lib\asan\asan_rtl.cc:505 "((!asan_init_is_running && "ASan init calls itself!")) != (0)" (0x0, 0x0) ==748==AddressSanitizer CHECK failed: D:\src\llvm_package_300231\llvm\projects\compiler-rt\lib\asan\asan_poisoning.cc:37 "((AddrIsInMem(addr))) != (0)" (0x0, 0x0) even if 'test.cpp' is just an empty With test.obj : error LNK2019: unresolved external symbol __asan_shadow_memory_dynamic_address referenced in function "struct Catch::IResultCapture & __cdecl Catch::getResultCapture(void)" (?getResultCapture@Catch@@YAAEAUIResultCapture@1@XZ) test.obj : error LNK2019: unresolved external symbol __asan_option_detect_stack_use_after_return referenced in function "struct Catch::IResultCapture & __cdecl Catch::getResultCapture(void)" (?getResultCapture@Catch@@YAAEAUIResultCapture@1@XZ) test.exe : fatal error LNK1120: 2 unresolved externals |
Is ASan supported under Windows? Last time I checked, it was "this will very likely work for C, C++ is very much beta". |
Hello. Now that Address Sanitizer is Generally Available for MSVC, I've noticed that I'm unable to run my tests due to this issue--they get stuck and won't complete. After some digging, I found a relevant open issue on Microsoft's tracker with a potential workaround that would consist of the following (naive) change to Catch here
Catch2/single_include/catch2/catch.hpp Line 10787 in b025a00
- exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException);
+ exceptionHandlerHandle = AddVectoredExceptionHandler(0, handleVectoredException); I've tested this change locally with a modified (read: updated) version of the batch script in the OP with a fully updated Visual Studio (v16.9.1) on latest Catch (v2.13.4), and it seems to run to completion! echo #define CATCH_CONFIG_MAIN > test.cpp
echo #include "catch.hpp" >> test.cpp
echo TEST_CASE( "t", "[t]" ) { REQUIRE( 2 == 1 ); } >> test.cpp
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
echo Please wait...
cl /EHsc test.cpp -fsanitize=address -c
link /DEBUG test.obj
start test.exe However, I don't understand the consequences of this change and how it could affect the rest of Catch's logic and exception handling, so hopefully this helps one of the maintainers or someone else more familiar with the code base and C++ in general 🙂 |
This is related to the way asan is implemented on x64 msvc. See here doc. catch2+asan+msvc is working on x86 unmodified (but nobody builds for x86 anymore) Maybe catch2 could offer an option to give up on first chance exception or do it automatically on x64 with
|
as a workaround, setting |
ASAN on Windows messes with exception handlers, and Catch2 doesn't account for this. A workaround is to disable SEH on Windows with ASAN as suggested in this reply to an existing issue catchorg/Catch2#898 (comment)
ASAN on Windows messes with exception handlers, and Catch2 doesn't account for this. A workaround is to disable SEH on Windows with ASAN as suggested in this reply to an existing issue catchorg/Catch2#898 (comment)
ASAN on Windows messes with exception handlers, and Catch2 doesn't account for this. A workaround is to disable SEH on Windows with ASAN as suggested in this reply to an existing issue catchorg/Catch2#898 (comment) CI requires some sourcing of the development tools for required paths
ASAN on Windows messes with exception handlers, and Catch2 doesn't account for this. A workaround is to disable SEH on Windows with ASAN as suggested in this reply to an existing issue catchorg/Catch2#898 (comment) CI requires some sourcing of the development tools for required paths
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 catchorg#2332 Closes catchorg#2286 Closes catchorg#898
Description
Catch enters infinite recursion trying to print error message when compiled with clang -faddress-sanitize under Windows
Steps to reproduce
catch.hpp
andtest.bat
from test.zip in one directory, starttest.bat
and then it will crash.
The text was updated successfully, but these errors were encountered: