Skip to content

<optional>: Add Address Sanitizer annotations#6010

Open
ozguronsoy wants to merge 8 commits intomicrosoft:mainfrom
ozguronsoy:optional-asan
Open

<optional>: Add Address Sanitizer annotations#6010
ozguronsoy wants to merge 8 commits intomicrosoft:mainfrom
ozguronsoy:optional-asan

Conversation

@ozguronsoy
Copy link

When optional is empty the internal storage is poisoned, it's unpoisoned when a value is assigned.

  • Added _ANNOTATE_OPTIONAL, _DISABLE_OPTIONAL_ANNOTATION, etc. to __msvc_sanitizer_annotate_container.hpp.
  • Added poisoning storage in _Optional_destruct_base on empty construction and reset.
  • Added unpoisoning of storage in _Optional_construct_base::_Construct.
  • Added poisoning and unpoisoning tests.

Resolves #5974

@ozguronsoy ozguronsoy requested a review from a team as a code owner January 14, 2026 00:23
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Jan 14, 2026
@ozguronsoy
Copy link
Author

@microsoft-github-policy-service agree

@StephanTLavavej StephanTLavavej changed the title Add address sanitizer annotations to optional <optional>: Add Address Sanitizer annotations Jan 14, 2026
@StephanTLavavej StephanTLavavej added enhancement Something can be improved ASan Address Sanitizer labels Jan 14, 2026
@StephanTLavavej

This comment was marked as resolved.

#endif
} // extern "C"

#if defined(_INSERT_VECTOR_ANNOTATION) || defined(_INSERT_STRING_ANNOTATION)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a concentrated controlling macro for these.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary since this check is only done here. I also added defined(_INSERT_OPTIONAL_ANNOTATION) to the check.

@ozguronsoy
Copy link
Author

Hi @StephanTLavavej, since the <flat_map> and <flat_set> have landed, can we move on with the review when you are available?

@StephanTLavavej
Copy link
Member

Yes, I'm trying to get through my PR review backlog. I know you've been waiting a month, for which I apologize. I'm the only maintainer flying this jumbo jet at the moment, so I ask for your patience!

@ozguronsoy
Copy link
Author

Wow that must be tough. It's no problem, I can wait.

Copy link
Member

@davidmrdavid davidmrdavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@StephanTLavavej StephanTLavavej moved this from Initial Review to Work In Progress in STL Code Reviews Feb 26, 2026
@StephanTLavavej StephanTLavavej moved this from Work In Progress to Initial Review in STL Code Reviews Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ASan Address Sanitizer enhancement Something can be improved

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

<optional>: address sanitizer annotation

5 participants