-
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
Support instrumenting the STL with ASan #4313
Conversation
VSO-1913897 is the result the STL's early initialization of locale and stream data - which must happen before init of user globals so their initializers can use streams - being instrumented with ASan and sometimes running before the ASan initialization. This change adds a new force-included header `vso1913897.hpp` that dynamically initializes a `thread_local`; programs that use TLS engage a more reliable early initialization path in the ASan runtime.
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.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
STL-ASan-CI validation: https://dev.azure.com/vclibs/STL/_build/results?buildId=15919&view=results |
LGTM. I pushed a conflict-free merge with |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
I had to push a commit because
|
Thanks for this major ASan achievement! 🧗 ⛰️ 😻 |
Add support for instrumenting the STL with ASan by setting the
STL_ASAN_BUILD
cmake option and enable this support in the STL-ASan-CI pipeline. This lets us run "full ASan" tests with coverage of the header-only code and binary libraries. For now that requires client programs to be ASan instrumented since they statically link with either the entire STL (/MT
or/MTd
) or the contents of the import library (/MD
or/MDd
).This includes a fairly icky workaround for an initialization ordering bug (VSO-1913897) which injects a dynamically-initialized
thread_local
into each test TU. It's a matter of opinion whether it's more horrible to have ASan and non-ASan test coverage diverge by using this workaround only for ASan testing, or more horrible to have the ASan workaround affect non-ASan testing. I've chosen to use the workaround universally. This should truly be temporary since there's ongoing work to fix the issue with a coordinated change in the compiler and ASan runtime.Drive-by: increase paranoia around google/sanitizers#328. This change isn't strictly needed but would have saved me some time and confusion.
.. to add
tests/std/include
to the include path for the libc++ test suite to support the VSO-1913897 workaround.