folly
folly copied to clipboard
Add address sanitizer annotations to UninitializedMemoryHacks.h when building with msvc 2022
I use UninitializedMemoryHacks.h, but it adds lots of false positives when running with address sanitizer. I grepped MS includes and based on the version that comes with VS2022 I added these annotations. In my case, this fixed all the issues. I did check vs 2019 headers and didn't see the same annotation code used there.
check __sanitizer_annotate_contiguous_container in https://github.com/microsoft/STL/blob/main/stl/inc/string and https://github.com/microsoft/STL/blob/main/stl/inc/vector
based on git history, seems that these are available only in vs 2022:
@Orvid has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
FYI, it looks like in current version that ships with latest VS2022 asan annotations are commented out in std::string
. I had some false positives because of that with asan reporting and had to comment out the string part in UninitializedMemoryHacks.h
More fixes added (support for std::string annotations was added starting from _MSC_VER >= 1938)
Has folly considered asking for an _Ugly member that does what they need rather than trying to incapability declare standard library parts?
@Orvid has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@yfeldblum thanks for the review. I'm traveling in remote locations and rarely connect, so, will take some time before I can address it. There was also a suggestion by @BillyONeal and I think that would be a better approach.
There was also a suggestion by @BillyONeal and I think that would be a better approach.
To be clear, while in the long term doing this with some mechanism that isn't a hack would have the benefit that it doesn't break every 3 seconds.
That doesn't change that VS2022 17.8 is already out there which means Windows customers who want to use Folly are broken
@yfeldblum all issues should be addressed
_INSERT_STRING_ANNOTATION
/ _INSERT_VECTOR_ANNOTATION
are defined by https://github.com/microsoft/STL/blob/0403d19f5461fd15983737c3f01ec34800ea9275/stl/inc/__msvc_sanitizer_annotate_container.hpp (this file is included by string/vector). string/vector undef these defines at the end. This PR replicates what the MS headers do.
_Asan_string_should_annotate
also comes from __msvc_sanitizer_annotate_container.hpp
@yfeldblum ping
@Orvid has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@Orvid has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
There are merge conflicts in this that need to be resolved before the tooling will let me import this PR. Would you be able to rebase this PR?
There are merge conflicts in this that need to be resolved before the tooling will let me import this PR. Would you be able to rebase this PR?
give me a few mins
I rebased, but I didn't have any merge conflicts. @Orvid @yfeldblum
@Orvid has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
Thanks, the import worked that time. Not sure why it was having issues before if there weren't merge conflicts.