From a4007e944fe2e3d08aab547baeb2d5a4a59cbdc8 Mon Sep 17 00:00:00 2001
From: Abseil Team <absl-team@google.com>
Date: Wed, 24 Jun 2020 12:47:04 -0400
Subject: [PATCH] Googletest export

Make sure sanitizers do not tamper with the stack here in StackLowerThanAddress().

PiperOrigin-RevId: 318082465
---
 googletest/src/gtest-death-test.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 5d1031be..121d2bba 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -1284,8 +1284,13 @@ static int ExecDeathTestChildMain(void* child_arg) {
 // correct answer.
 static void StackLowerThanAddress(const void* ptr,
                                   bool* result) GTEST_NO_INLINE_;
+// Make sure sanitizers do not tamper with the stack here.
+// Ideally, we want to use `__builtin_frame_address` instead of a local variable
+// address with sanitizer disabled, but it does not work when the
+// compiler optimizes the stack frame out, which happens on PowerPC targets.
 // HWAddressSanitizer add a random tag to the MSB of the local variable address,
 // making comparison result unpredictable.
+GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
 GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
 static void StackLowerThanAddress(const void* ptr, bool* result) {
   int dummy;
-- 
GitLab