-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add the ability to opt-out of ASan container annotations on a per-allocator basis #5241
base: main
Are you sure you want to change the base?
Add the ability to opt-out of ASan container annotations on a per-allocator basis #5241
Conversation
Co-authored-by: Casey Carter <[email protected]>
Co-authored-by: Casey Carter <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
…sto/add-asan-per-container-disablement
…sto/add-asan-per-container-disablement
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool 👍
Is the plan to hold on merge while testing the FE?
Thanks, @zacklj89!
My current plan is to work on getting the FE to test this by Friday one way or another: either by manually porting this internally on a private branch, or by consuming this 'as normal' by merging this PR and mirror'ing it on ADO's default branch. So I think it depends on how quickly we can STL's final approval here. One way or another, I'll be working towards enabling this to be validated by FE starting tomorrow :) . Put another way: I don't think it's strictly necessary to block the PR merge on it - the feature and tests seems up to spec to me. But I'll defer to more experienced owners on that decision. |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for the feedback, I've taken notes on the common feedback items (don't shadow, don't add New diff seems sound to me, thanks. Good to merge afaict. |
Context:
The STL "annotates" the
vector
andbasic_string
containers so that ASan will reportcontainer-overflow
whenever allocated but un-initialized data is accessed.A simple repro is the
container overflow
error fired in this sample program (assuming it's/fsanitize=address
'ed):This is sensible behavior in most cases.
One case where it does not bode well is when an arena allocator is used as the custom allocator of the container. Arena allocators often tamper with the entire allocated memory at once (e.g. they commonly deallocate their entire 'arena' at once) which would trigger ASan AVs when the capacity of the container exceeds it's size.
We encountered one such bug in the
msvc
front end.This PR:
This PR introduces the ability for custom allocators to opt-out of
vector
andbasic_string
's ASan annotations. This is controlled by the newly introduced template variable:_Disable_ASan_container_annotations_for_allocator<...some allocator type...>
.Testing:
basic_string
andvector
respectivelybasic_string
, this replaces the recently addedtest_gh_5251
test (from ASan should detect writing to abasic_string
's reserved but uninitialized memory #5252) to avoid repetition.