diff options
author | Abseil Team <absl-team@google.com> | 2019-04-01 19:44:44 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2019-04-01 19:45:51 (GMT) |
commit | b617b277186e03b1065ac6d43912b1c4147c2982 (patch) | |
tree | b36d81fb9cfebb44c8f8aea1a26e839a9196fd57 /googletest/src/gtest-death-test.cc | |
parent | 2efd659a13e9127d65266c368c06466e2842b2e6 (diff) | |
download | googletest-b617b277186e03b1065ac6d43912b1c4147c2982.zip googletest-b617b277186e03b1065ac6d43912b1c4147c2982.tar.gz googletest-b617b277186e03b1065ac6d43912b1c4147c2982.tar.bz2 |
Googletest export
Add HWASan annotations.
These mirror existing ASan annotations.
HWASan uses memory (address) tagging to detect memory errors:
https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html
It inserts a random tag in the MSB of heap and stack allocation addresses. This tag dominates pointer comparison in StackGrowsDown(), making the result non-deterministic, and entirely unrelated to the actual stack growth direction. The function attribute disables this behavior.
The annotations in gtest-printers are there because the printers are used to basically dump memory. The sanitizers may have ideas why this memory should not be accessed, and that is counter productive. In particular, the test may access only part of an array, but in case of a test failure gtest will dump the entire array which may contain uninitialized bytes - that's what SANITIZE_MEMORY annotation is for. There are similar reasons for ADDRESS and THREAD annotations. HWADDRESS in its current implementation can not cause issues there, I believe, but it falls under the same umbrella of tools whose checking should not apply to test printers because it is not the code under test.
PiperOrigin-RevId: 241379822
Diffstat (limited to 'googletest/src/gtest-death-test.cc')
-rw-r--r-- | googletest/src/gtest-death-test.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc index d15e250..cd0ca05 100644 --- a/googletest/src/gtest-death-test.cc +++ b/googletest/src/gtest-death-test.cc @@ -1270,6 +1270,9 @@ static int ExecDeathTestChildMain(void* child_arg) { // correct answer. static void StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_; +// HWAddressSanitizer add a random tag to the MSB of the local variable address, +// making comparison result unpredictable. +GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ static void StackLowerThanAddress(const void* ptr, bool* result) { int dummy; *result = (&dummy < ptr); @@ -1277,6 +1280,7 @@ static void StackLowerThanAddress(const void* ptr, bool* result) { // Make sure AddressSanitizer does not tamper with the stack here. GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ static bool StackGrowsDown() { int dummy; bool result; |