summaryrefslogtreecommitdiffstats
path: root/googletest/src/gtest-printers.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-04-01 19:44:44 (GMT)
committerGennadiy Civil <misterg@google.com>2019-04-01 19:45:51 (GMT)
commitb617b277186e03b1065ac6d43912b1c4147c2982 (patch)
treeb36d81fb9cfebb44c8f8aea1a26e839a9196fd57 /googletest/src/gtest-printers.cc
parent2efd659a13e9127d65266c368c06466e2842b2e6 (diff)
downloadgoogletest-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-printers.cc')
-rw-r--r--googletest/src/gtest-printers.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc
index 5325ef2..40a8817 100644
--- a/googletest/src/gtest-printers.cc
+++ b/googletest/src/gtest-printers.cc
@@ -59,6 +59,7 @@ using ::std::ostream;
// Prints a segment of bytes in the given object.
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
+GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,
size_t count, ostream* os) {
@@ -260,6 +261,7 @@ void PrintTo(wchar_t wc, ostream* os) {
template <typename CharType>
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
+GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
static CharFormat PrintCharsAsStringTo(
const CharType* begin, size_t len, ostream* os) {
@@ -290,6 +292,7 @@ static CharFormat PrintCharsAsStringTo(
template <typename CharType>
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
+GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
static void UniversalPrintCharArray(
const CharType* begin, size_t len, ostream* os) {