Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
628 Discussions

icx with enabled address sanitizer under Windows and C++ throw crash

Frank_R_1
Beginner
402 Views

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

0 Kudos
1 Solution
Sravani_K_Intel
Moderator
104 Views

Hi,

This compilation error has been resolved and the fix can be expected in the upcoming compiler release.


View solution in original post

0 Kudos
5 Replies
Alex_Y_Intel
Moderator
340 Views

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

0 Kudos
Frank_R_1
Beginner
289 Views

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

0 Kudos
Frank_R_1
Beginner
269 Views

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

0 Kudos
Alex_Y_Intel
Moderator
256 Views

I've escalated your issue to our internal engineering team. We'll come back with the update when we reach the conclusion. 

0 Kudos
Sravani_K_Intel
Moderator
105 Views

Hi,

This compilation error has been resolved and the fix can be expected in the upcoming compiler release.


0 Kudos
Reply