-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Re-enable ASAN string annotations #3164
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
Merged
Stephan T. Lavavej (StephanTLavavej)
merged 33 commits into
microsoft:main
from
strega-nil:anno-asan01
Dec 15, 2022
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
b1cfcde
initial attempt
strega-nil 34bacc1
moar tests
strega-nil d51e580
CRs, plus some more minor work
strega-nil c62e749
minor code quality
strega-nil 997f9b7
fix vector
strega-nil f108c24
fix stuff with testing
strega-nil 86642d0
fixey fixey format
strega-nil 277e68b
casey crs
strega-nil b76170a
fix comment
strega-nil 99ea61a
moar fixin
strega-nil 65dbe64
[ci skip] [wip] re-enable tests
strega-nil d869441
ooh, tests are passing!
strega-nil 90ed742
oh okay, so you need to align both first and end
strega-nil 7f52caa
CRs, plus fix vector test
strega-nil 8afead5
add test for DevCom-10109507
strega-nil 888cc8b
please tell me i actually fixed the tests this time
strega-nil dfaa6b1
ooh we can actually DO MORE
strega-nil 42ef1a5
blampley blample more example
strega-nil 9f503ca
remove noexcept from asan function
strega-nil f80f166
Amy CRs; force strings to be aligned on 4
strega-nil 1641a6e
I dunno why this wasn't formatted
strega-nil f7cdbfb
Merge remote-tracking branch 'origin/main' into strega-nil/anno-asan01
strega-nil f12db09
Stephan CRs
strega-nil 840cae1
misc cleanups
strega-nil 6e37b5c
fix tests
strega-nil 74f8320
forgot to format as I was copying back and forth
strega-nil cc418a3
zack's CRs
strega-nil f6984d8
xstring: remove memcpies in `_INSERT_STRING_ANNOTATION` mode
strega-nil 13b122f
Merge remote-tracking branch 'origin/main' into strega-nil/anno-asan01
strega-nil ace0d8b
ughghghughuhughg
strega-nil b413060
Merge remote-tracking branch 'origin/main' into strega-nil/anno-asan01
strega-nil 1f55a10
remove SBO annotations
strega-nil e38dd35
minor CRs
strega-nil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| // __msvc_sanitizer_annotate_container.hpp internal header | ||
|
|
||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #pragma once | ||
| #ifndef __MSVC_SANITIZER_ANNOTATE_CONTAINER_HPP | ||
| #define __MSVC_SANITIZER_ANNOTATE_CONTAINER_HPP | ||
| #include <yvals_core.h> | ||
| #if _STL_COMPILER_PREPROCESSOR | ||
|
|
||
|
strega-nil-ms marked this conversation as resolved.
|
||
| #pragma pack(push, _CRT_PACKING) | ||
| #pragma warning(push, _STL_WARNING_LEVEL) | ||
| #pragma warning(disable : _STL_DISABLED_WARNINGS) | ||
| _STL_DISABLE_CLANG_WARNINGS | ||
| #pragma push_macro("new") | ||
| #undef new | ||
|
|
||
| #if !defined(_M_CEE_PURE) && !(defined(_DISABLE_STRING_ANNOTATION) && defined(_DISABLE_VECTOR_ANNOTATION)) | ||
|
|
||
| #ifdef __SANITIZE_ADDRESS__ | ||
|
|
||
| #define _ACTIVATE_STRING_ANNOTATION | ||
| #define _INSERT_STRING_ANNOTATION | ||
| #define _ACTIVATE_VECTOR_ANNOTATION | ||
| #define _INSERT_VECTOR_ANNOTATION | ||
|
|
||
| #elif defined(__clang__) // ^^^ __SANITIZE_ADDRESS__ / __clang__ vvv | ||
|
|
||
| #if __has_feature(address_sanitizer) | ||
| #define _ACTIVATE_STRING_ANNOTATION | ||
| #define _INSERT_STRING_ANNOTATION | ||
| #define _ACTIVATE_VECTOR_ANNOTATION | ||
| #define _INSERT_VECTOR_ANNOTATION | ||
| #pragma comment(linker, "/INFERASANLIBS") | ||
| #endif // __has_feature(address_sanitizer) | ||
|
|
||
| #else // ^^^ __clang__ / !__clang__ && !__SANITIZE_ADDRESS__ vvv | ||
|
|
||
| #ifdef _ANNOTATE_STRING | ||
| #define _INSERT_STRING_ANNOTATION | ||
| #endif // _ANNOTATE_STRING | ||
| #ifdef _ANNOTATE_VECTOR | ||
| #define _INSERT_VECTOR_ANNOTATION | ||
| #endif // _ANNOTATE_VECTOR | ||
|
|
||
| #endif // __SANITIZE_ADDRESS__ | ||
|
|
||
| #ifdef _DISABLE_STRING_ANNOTATION | ||
| #undef _ACTIVATE_STRING_ANNOTATION | ||
| #undef _INSERT_STRING_ANNOTATION | ||
| #endif // _DISABLE_STRING_ANNOTATION | ||
| #ifdef _DISABLE_VECTOR_ANNOTATION | ||
| #undef _ACTIVATE_VECTOR_ANNOTATION | ||
| #undef _INSERT_VECTOR_ANNOTATION | ||
| #endif // _DISABLE_VECTOR_ANNOTATION | ||
|
|
||
| #ifndef _INSERT_STRING_ANNOTATION | ||
| #pragma detect_mismatch("annotate_string", "0") | ||
| #endif // !_INSERT_STRING_ANNOTATION | ||
| #ifndef _INSERT_VECTOR_ANNOTATION | ||
| #pragma detect_mismatch("annotate_vector", "0") | ||
| #endif // !_INSERT_VECTOR_ANNOTATION | ||
|
|
||
| #ifdef _ACTIVATE_STRING_ANNOTATION | ||
| #pragma comment(lib, "stl_asan") | ||
| #pragma detect_mismatch("annotate_string", "1") | ||
| #endif // _ACTIVATE_STRING_ANNOTATION | ||
| #ifdef _ACTIVATE_VECTOR_ANNOTATION | ||
| #pragma comment(lib, "stl_asan") | ||
| #pragma detect_mismatch("annotate_vector", "1") | ||
| #endif // _ACTIVATE_VECTOR_ANNOTATION | ||
|
|
||
| #undef _ACTIVATE_STRING_ANNOTATION | ||
| #undef _ACTIVATE_VECTOR_ANNOTATION | ||
|
|
||
| extern "C" { | ||
| #ifdef _INSERT_VECTOR_ANNOTATION | ||
| extern const bool _Asan_vector_should_annotate; | ||
| #endif | ||
|
|
||
| #ifdef _INSERT_STRING_ANNOTATION | ||
| extern const bool _Asan_string_should_annotate; | ||
| #endif | ||
| } | ||
|
|
||
| #if defined(_INSERT_VECTOR_ANNOTATION) || defined(_INSERT_STRING_ANNOTATION) | ||
| extern "C" { | ||
| void __cdecl __sanitizer_annotate_contiguous_container( | ||
| const void* _First, const void* _End, const void* _Old_last, const void* _New_last); | ||
| } | ||
|
|
||
| #ifdef _M_ARM64EC | ||
| #pragma comment(linker, \ | ||
| "/alternatename:#__sanitizer_annotate_contiguous_container=#__sanitizer_annotate_contiguous_container_default") | ||
| #pragma comment(linker, \ | ||
| "/alternatename:__sanitizer_annotate_contiguous_container=__sanitizer_annotate_contiguous_container_default") | ||
| #pragma comment(linker, "/alternatename:#_Asan_vector_should_annotate=#_Asan_vector_should_annotate_default") | ||
| #pragma comment(linker, "/alternatename:_Asan_vector_should_annotate=_Asan_vector_should_annotate_default") | ||
| #pragma comment(linker, "/alternatename:#_Asan_string_should_annotate=#_Asan_string_should_annotate_default") | ||
| #pragma comment(linker, "/alternatename:_Asan_string_should_annotate=_Asan_string_should_annotate_default") | ||
| #elif defined(_M_HYBRID) | ||
| #pragma comment(linker, \ | ||
| "/alternatename:#__sanitizer_annotate_contiguous_container=#__sanitizer_annotate_contiguous_container_default") | ||
| #pragma comment(linker, \ | ||
| "/alternatename:___sanitizer_annotate_contiguous_container=___sanitizer_annotate_contiguous_container_default") | ||
| #pragma comment(linker, "/alternatename:#_Asan_vector_should_annotate=#_Asan_vector_should_annotate_default") | ||
| #pragma comment(linker, "/alternatename:__Asan_vector_should_annotate=__Asan_vector_should_annotate_default") | ||
| #pragma comment(linker, "/alternatename:#_Asan_string_should_annotate=#_Asan_string_should_annotate_default") | ||
| #pragma comment(linker, "/alternatename:__Asan_string_should_annotate=__Asan_string_should_annotate_default") | ||
| #elif defined(_M_IX86) | ||
| #pragma comment(linker, \ | ||
| "/alternatename:___sanitizer_annotate_contiguous_container=___sanitizer_annotate_contiguous_container_default") | ||
| #pragma comment(linker, "/alternatename:__Asan_vector_should_annotate=__Asan_vector_should_annotate_default") | ||
| #pragma comment(linker, "/alternatename:__Asan_string_should_annotate=__Asan_string_should_annotate_default") | ||
| #elif defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64) | ||
| #pragma comment(linker, \ | ||
| "/alternatename:__sanitizer_annotate_contiguous_container=__sanitizer_annotate_contiguous_container_default") | ||
| #pragma comment(linker, "/alternatename:_Asan_vector_should_annotate=_Asan_vector_should_annotate_default") | ||
| #pragma comment(linker, "/alternatename:_Asan_string_should_annotate=_Asan_string_should_annotate_default") | ||
| #else // ^^^ known architecture / unknown architecture vvv | ||
| #error Unknown architecture | ||
| #endif // ^^^ unknown architecture ^^^ | ||
|
|
||
| #endif // insert asan annotations | ||
|
|
||
| #endif // !_M_CEE_PURE && asan not disabled | ||
|
|
||
| #pragma pop_macro("new") | ||
| _STL_RESTORE_CLANG_WARNINGS | ||
| #pragma warning(pop) | ||
| #pragma pack(pop) | ||
|
|
||
| #endif // _STL_COMPILER_PREPROCESSOR | ||
| #endif // __MSVC_SANITIZER_ANNOTATE_CONTAINER_HPP | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.