Skip to content

Commit

Permalink
[win][ASAN] Fix ASAN build on Windows
Browse files Browse the repository at this point in the history
On Windows, even `__declspec(no_sanitize_address)` does not prevent
the `heap-use-after-free` errors when using the `/fsanitize=address`
compiler flag, so don't even try.
Fixes root-project#9445
  • Loading branch information
bellenot committed Oct 3, 2024
1 parent 2ec063a commit 228a4f8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/base/src/TObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ bool DeleteChangesMemoryImpl()
// can guess this is always the case and we can rely on the changes to fBits made
// by ~TObject to detect use-after-delete error (and print a message rather than
// stop the program with a segmentation fault)
if ( *o_fbits != 0x01000000 ) {
#if defined(_MSC_VER) && defined(__SANITIZE_ADDRESS__)
// on Windows, even __declspec(no_sanitize_address) does not prevent catching
// heap-use-after-free errorswhen using the /fsanitize=address compiler flag
// so don't even try
return true;
#endif
if ( *o_fbits != 0x01000000 ) {
// operator delete tainted the memory, we can not rely on TestBit(kNotDeleted)
return true;
}
Expand Down

0 comments on commit 228a4f8

Please sign in to comment.