-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Allow ASan container annotations to activate piecemeal #6211
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
Open
amyw-msft
wants to merge
9
commits into
microsoft:main
Choose a base branch
from
amyw-msft:partial-asan-annotation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
62e7af2
Remove stl_asan.lib as a dependency so that annotations can be activa…
amyw-msft d1baeac
Add comments to stl_asan.lib definitions.
amyw-msft fc4fbf6
Responding to feedback. Update __msvc_sanitizer_annotate_container.hp…
amyw-msft fcd61e0
Merge branch 'main' into partial-asan-annotation
StephanTLavavej 26006f1
Add extern.
StephanTLavavej 88089e5
Fix grammar: defines => define
StephanTLavavej 65bdbf8
Style: Move `__declspec(selectany)` to the beginning.
StephanTLavavej 3c0c2fd
Update test declarations to match headers.
StephanTLavavej 88995c6
asan.cpp: Drop `namespace std` outside `extern "C"`.
StephanTLavavej 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 |
|---|---|---|
| @@ -1,10 +1,14 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| namespace std { | ||
| extern "C" { | ||
| extern const bool _Asan_string_should_annotate = true; | ||
| extern const bool _Asan_vector_should_annotate = true; | ||
| extern const bool _Asan_optional_should_annotate = true; | ||
| } // extern "C" | ||
| } // namespace std | ||
| extern "C" { | ||
| // TRANSITION, ABI: preserved for compatibility with old headers, which | ||
| // added stl_asan.lib to the link line. We use __declspec(selectany) to be | ||
| // compatible with the new headers that define these variables as | ||
| // __declspec(selectany) in __msvc_sanitizer_annotate_container.hpp. | ||
| // The new method is preferred because previously enabling just string | ||
| // would also enable vector and optional. See GH-6186 for details. | ||
| __declspec(selectany) extern const bool _Asan_string_should_annotate = true; | ||
| __declspec(selectany) extern const bool _Asan_vector_should_annotate = true; | ||
| __declspec(selectany) extern const bool _Asan_optional_should_annotate = true; | ||
| } // extern "C" |
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,40 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| # This test matrix is the usual test matrix, with all currently unsupported options removed, crossed with the ASan flags. | ||
|
|
||
| # TRANSITION, google/sanitizers#328: clang-cl does not support /MDd or /MTd with ASan | ||
| RUNALL_INCLUDE ..\prefix.lst | ||
| RUNALL_CROSSLIST | ||
| PM_CL="/fsanitize=address /DTEST_ENSURE_VECTOR_ENABLED /DTEST_ENSURE_STRING_ENABLED /DTEST_ENSURE_OPTIONAL_ENABLED" | ||
| PM_CL="/fsanitize=address /D_DISABLE_VECTOR_ANNOTATION /DTEST_ENSURE_STRING_ENABLED /DTEST_ENSURE_OPTIONAL_ENABLED" | ||
| PM_CL="/fsanitize=address /DTEST_ENSURE_VECTOR_ENABLED /D_DISABLE_STRING_ANNOTATION /DTEST_ENSURE_OPTIONAL_ENABLED" | ||
| PM_CL="/fsanitize=address /DTEST_ENSURE_VECTOR_ENABLED /DTEST_ENSURE_STRING_ENABLED /D_DISABLE_OPTIONAL_ANNOTATION" | ||
| PM_CL="/D_ANNOTATE_STL" | ||
| RUNALL_CROSSLIST | ||
| PM_CL="/Zi /wd4611 /w14640 /Zc:threadSafeInit-" PM_LINK="/debug" | ||
| RUNALL_CROSSLIST | ||
| PM_CL="/BE /c /EHsc /MD /std:c++14" | ||
| PM_CL="/BE /c /EHsc /MDd /std:c++17 /permissive-" | ||
| PM_CL="/BE /c /EHsc /MT /std:c++20 /permissive-" | ||
| PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive-" | ||
| PM_CL="/EHsc /MD /std:c++14" | ||
| PM_CL="/EHsc /MD /std:c++17" | ||
| PM_CL="/EHsc /MD /std:c++20" | ||
| PM_CL="/EHsc /MD /std:c++latest /permissive- /Zc:char8_t- /Zc:preprocessor" | ||
| PM_CL="/EHsc /MD /std:c++latest /permissive- /Zc:noexceptTypes-" | ||
| PM_CL="/EHsc /MDd /std:c++14 /fp:except /Zc:preprocessor" | ||
| PM_CL="/EHsc /MDd /std:c++17 /permissive-" | ||
| PM_CL="/EHsc /MDd /std:c++20 /permissive-" | ||
| PM_CL="/EHsc /MDd /std:c++latest /permissive- /Zc:wchar_t-" | ||
| PM_CL="/EHsc /MDd /std:c++latest /permissive-" | ||
| PM_CL="/EHsc /MT /std:c++latest /permissive- /analyze:only /analyze:autolog-" | ||
| PM_CL="/EHsc /MT /std:c++latest /permissive-" | ||
| PM_CL="/EHsc /MTd /std:c++latest /permissive" | ||
| PM_CL="/EHsc /MTd /std:c++latest /permissive- /analyze:only /analyze:autolog-" | ||
| PM_CL="/EHsc /MTd /std:c++latest /permissive- /fp:strict" | ||
| PM_CL="/EHsc /MTd /std:c++latest /permissive-" | ||
| PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MD /std:c++14" | ||
| PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MD /std:c++17" | ||
| PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-" | ||
| PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict" | ||
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,40 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| // REQUIRES: x64 || x86 || arm64 | ||
|
amyw-msft marked this conversation as resolved.
|
||
|
|
||
| #if defined(__clang__) && defined(_M_ARM64) // TRANSITION, LLVM-184902, fixed in Clang 23 | ||
| #pragma comment(linker, "/INFERASANLIBS") | ||
| int main() {} | ||
| #else // ^^^ workaround / no workaround vvv | ||
|
|
||
| #include <cassert> | ||
| #include <vector> // include __msvc_sanitizer_annotate_container.hpp | ||
|
|
||
| extern "C" { | ||
| extern const bool _Asan_vector_should_annotate; | ||
| extern const bool _Asan_string_should_annotate; | ||
| extern const bool _Asan_optional_should_annotate; | ||
| } // extern "C" | ||
|
|
||
| int main() { | ||
| #ifdef TEST_ENSURE_VECTOR_ENABLED | ||
| assert(_Asan_vector_should_annotate == true); | ||
| #else | ||
| assert(_Asan_vector_should_annotate == false); | ||
| #endif | ||
|
|
||
| #ifdef TEST_ENSURE_STRING_ENABLED | ||
| assert(_Asan_string_should_annotate == true); | ||
| #else | ||
| assert(_Asan_string_should_annotate == false); | ||
| #endif | ||
|
|
||
| #ifdef TEST_ENSURE_OPTIONAL_ENABLED | ||
| assert(_Asan_optional_should_annotate == true); | ||
| #else | ||
| assert(_Asan_optional_should_annotate == false); | ||
| #endif | ||
| } | ||
|
|
||
| #endif // ^^^ no workaround ^^^ | ||
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.