<optional>: Add Address Sanitizer annotations#6010
<optional>: Add Address Sanitizer annotations#6010ozguronsoy wants to merge 15 commits intomicrosoft:mainfrom
<optional>: Add Address Sanitizer annotations#6010Conversation
|
@microsoft-github-policy-service agree |
<optional>: Add Address Sanitizer annotations
This comment was marked as resolved.
This comment was marked as resolved.
297ab67 to
1be4772
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
davidmrdavid
left a comment
There was a problem hiding this comment.
Left some very minor feedback. The implementation seems sound, but from comparing the test matrix to the one in the asan vector and asan string annotations, I suspect we'll need a few more scenarios. I'll defer to @StephanTLavavej as usual.
This comment was marked as resolved.
This comment was marked as resolved.
|
I reviewed the product code and pushed changes to merge #include <optional>
#include <print>
#include <string>
#include <variant>
using namespace std;
int main() {
variant<optional<string>, int> var{"cats"};
println("{}", get<0>(var).value());
var = 1729;
println("{}", get<1>(var));
}Click to expand full ASan diagnostic:I arrived at this realization by noticing the asymmetry between the trivial dtor and non-trivial dtor cases, which got me thinking about the poisoned/unpoisoned state of the memory after the The problem is that if an
Lines 701 to 704 in 2626cf1 I'm going to need to run this past our ASan experts to see if some part of these changes can be salvaged. I expect that the trivial dtor case can't be salvaged. However, it might be possible to annotate the non-trivial dtor case; for the lifetime of the Please hold off on making changes to this PR while I go check. I'll also want to add the |
When
optionalis empty the internal storage is poisoned, it's unpoisoned when a value is assigned. We need to unpoison in the destructor, so the annotations must be restricted to non-trivially destructible value types._ANNOTATE_OPTIONAL,_DISABLE_OPTIONAL_ANNOTATION, etc. to__msvc_sanitizer_annotate_container.hpp._Optional_destruct_baseon empty construction andreset._Optional_construct_base::_Constructand~_Optional_destruct_base().Resolves #5974