Allow ASan container annotations to activate piecemeal#6211
Open
amyw-msft wants to merge 2 commits intomicrosoft:mainfrom
Open
Allow ASan container annotations to activate piecemeal#6211amyw-msft wants to merge 2 commits intomicrosoft:mainfrom
amyw-msft wants to merge 2 commits intomicrosoft:mainfrom
Conversation
…ted piecemeal. The lib is retained for compatibility with static libraries built with old headers.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix addressing #6186.
Previously, ASan annotations for
string,vector, andoptionalwere activated by linking withstl_asan.libwhich set each activation variable to true, leading to ODR violations if some TUs were built with annotations inserted but partially activated.This change removes the
stl_asan.libdependency and allows each option to set the activation variable individually.I've retained
stl_asan.liband modified the definitions with__declspec(selectany)to match those in the headers, and also to ensure compatibility if linking with a static library from a previous version of the toolset.The test I've included just ensures the annotations can be targeted individually instead of constructing an ASan error. I did this for simplicity (esp as new annotations are added) while still covering every scenario. I limited it to one disabled out of the set instead of exhaustive validation to not devote too much test time to this.
I've verified the scenario from #6186 locally, as well as ensuring it is backwards compatible with old versions of the headers (meaning, I built the annotated_lib.lib with an old toolset and test.obj with a toolset with this change and manually tried out every combination). Building a static library with the new toolset and linking with an old toolset produces a link error (the old
stl_asan.libdoes not contain__declspec(selectany), so clashes with the definition added in__msvc_sanitizer_annotate_container.hpp), but my understanding is that this isn't a supported scenario.