Hi,
Consider the following reproducer:
//////////////////////////////////////////////////////////////////////
// icx.exe -O3 -Ob2 -Zi -EHsc -MD -fsanitize=address test.cxx
// ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0,halt_on_error=0,detect_stack_use_after_return=true,check_initialization_order=true,check_malloc_usable_size=0,detect_odr_violation=1,handle_segv=1
#include <cstdio>
#include <exception>
int main(){
try {
throw std::exception("test");
}catch (const std::exception& ex){
puts(ex.what());
}
return 0;
}
Program will terminate with:
>./test.exe
=================================================================
==13688==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000000 (pc 0x7ff791b212a7 bp 0x0056ce4ffb20 sp 0x0056ce4fd260 T0)
==13688==The signal is caused by a READ memory access.
==13688==Hint: address points to the zero page.
#0 0x7ff791b212a6 in main D:\tmp\exception\test.cxx:9
#1 0x7ffb6463105f (C:\Windows\SYSTEM32\VCRUNTIME140.dll+0x18000105f)
#2 0x7ffb64634d37 (C:\Windows\SYSTEM32\VCRUNTIME140.dll+0x180004d37)
#3 0x7ffb6cd11715 (C:\Windows\SYSTEM32\ntdll.dll+0x1800a1715)
#4 0x7ff791b211af in main D:\tmp\exception\test.cxx:7
#5 0x7ff791b21c7f in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
#6 0x7ff791b21c7f in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
#7 0x7ffb6b4b7343 (C:\Windows\System32\KERNEL32.DLL+0x180017343)
#8 0x7ffb6ccc26b0 (C:\Windows\SYSTEM32\ntdll.dll+0x1800526b0)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: access-violation D:\tmp\exception\test.cxx:9 in main
==13688==ABORTING
Consider also:
https://github.com/google/sanitizers/issues/749
So address sanitizer is not useable under Windows in C++ programs with throw instructions.
Is there a workaround?
Best regards
Frank
Hi,
This compilation error has been resolved and the fix can be expected in the upcoming compiler release.
連結已複製
Do you meant that if you compiled like this: icx -O3 -Ob2 -Zi -EHsc -fsanitize=address test.cxx
You'd get the error you mentioned?
=================================================================
==19888==ERROR: AddressSanitizer: access-violation on unknown address 0x7ff60000000b (pc 0x7ff6982912a7 bp 0x00f008aff9c0 sp 0x00f008afd5e0 T0)
==19888==The signal is caused by a READ memory access.
#0 0x7ff6982912a6 in main C:\Users\ayu1\Project12\test.cxx:8
#1 0x7ff6982f453f in _CallSettingFrame D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\amd64\handlers.asm:49
#2 0x7ff6982e995b in __FrameHandler3::CxxCallCatchBlock(struct _EXCEPTION_RECORD *) D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp:1567
#3 0x7ffd5fbf4245 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x1800a4245)
#4 0x7ff6982911af in main C:\Users\ayu1\Project12\test.cxx:6
#5 0x7ff6982e46eb in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
#6 0x7ff6982e46eb in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
#7 0x7ffd5e98257c (C:\WINDOWS\System32\KERNEL32.DLL+0x18001257c)
#8 0x7ffd5fbaaa47 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x18005aa47)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: access-violation C:\Users\ayu1\Project12\test.cxx:8 in main
==19888==ABORTING
If I compiled like what you said icx -O3 -Ob2 -Zi -EHsc -MD -fsanitize=address test.cxx (with that -MD)
I actually got another error saying "the procedure entry point ??3@YAXPEAX@Z could not be located in the dynamic link library", which is the same problem you asked a few days ago: https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Windows-debug-build-with-icx-and-address-sanitizer-crash-with/m-p/1592947#M3683
Hi,
You need to copy
clang_rt.asan_dynamic-x86_64.dll
into your folder where the executable is located!
Then type
set ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0,halt_on_error=0,detect_stack_use_after_return=true,check_initialization_order=true,check_malloc_usable_size=0,detect_odr_violation=1,handle_segv=1
in your cmd.exe
and run
.\test.exe
=================================================================
==24444==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000000 (pc 0x7ff614ff12a7 bp 0x0006600ff8c0 sp 0x0006600fd000 T0)
==24444==The signal is caused by a READ memory access.
==24444==Hint: address points to the zero page.
#0 0x7ff614ff12a6 in main D:\tmp\test.cxx:11
#1 0x7ffb6463105f (C:\Windows\SYSTEM32\VCRUNTIME140.dll+0x18000105f)
#2 0x7ffb64634d37 (C:\Windows\SYSTEM32\VCRUNTIME140.dll+0x180004d37)
#3 0x7ffb6cd11715 (C:\Windows\SYSTEM32\ntdll.dll+0x1800a1715)
#4 0x7ff614ff11af in main D:\tmp\test.cxx:9
#5 0x7ff614ff1c7f in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
#6 0x7ffb6b4b7343 (C:\Windows\System32\KERNEL32.DLL+0x180017343)
#7 0x7ffb6ccc26b0 (C:\Windows\SYSTEM32\ntdll.dll+0x1800526b0)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: access-violation D:\tmp\test.cxx:11 in main
==24444==ABORTING
Best regards
Frank
Hi,
Just as an information:
On Linux everything works!
We have a lot of unit/integration/regression-tests which ran on Linux but fail on Windows due to exception handling problem of sanitizer : (
Best regards
Frank
Hi,
Unfortunately in Intel oneAPI 2024.2 with Windows 10/VS 2019 the reproducer below does not work!
#############################################################
//icx -Od -EHsc -Z7 ex.cxx
//works with output "Caught error no. 5 exception at ex.cxx in line 15"
//icx -Od -fsanitize=address -EHsc -Z7 ex.cxx
//crashes with "Caught error no. Segmentation fault"
#include<iostream>
struct Error {
int a;
};
void info(const char* f, const int l, const Error& e) {
std::cout << "Caught error no. " << e.a << " exception at " << f << " in line " << l << std::endl;
}
int main() {
try {
throw Error{5};
} catch (Error &e) {
info(__FILE__, __LINE__, e);
return 0;
}
return 1;
}
#############################################################
Everything on Linux now works very nice and stable, the exact same code base on Windows crashes in the exceptions catch. (Have a look in the debugger)
ASAN_OPTIONS are:
alloc_dealloc_mismatch=0,detect_leaks=0,halt_on_error=0,detect_stack_use_after_return=true,check_initialization_order=true,strict_string_checks=true,check_malloc_usable_size=true,detect_odr_violation=1,strict_init_order=1,use_odr_indicator=1,handle_segv=0
Best regards
Frank