[llvm] 4f0b0bf - Cherry-pick gtest fix for asan tests.

Evgenii Stepanov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 20 14:13:17 PST 2019


Author: Evgenii Stepanov
Date: 2019-11-20T14:12:51-08:00
New Revision: 4f0b0bf5c6731e3d370558be08c9261801263b09

URL: https://github.com/llvm/llvm-project/commit/4f0b0bf5c6731e3d370558be08c9261801263b09
DIFF: https://github.com/llvm/llvm-project/commit/4f0b0bf5c6731e3d370558be08c9261801263b09.diff

LOG: Cherry-pick gtest fix for asan tests.

Summary:
https://github.com/google/googletest/commit/681454dae48f109abf68c424c9d2e6db9a092238

Clone+exec death test allocates a single page of stack to run chdir + exec on.
This is not enough when gtest is built with ASan and run on particular
hardware.

With ASan on x86_64, ExecDeathTestChildMain has frame size of 1728 bytes.

Call to chdir() in ExecDeathTestChildMain ends up in
_dl_runtime_resolve_xsavec, which attempts to save register state on the stack;
according to cpuid(0xd) XSAVE register save area size is 2568 on my machine.

This results in something like this in all death tests:
  Result: died but not with expected error.
  ...
  [  DEATH   ] AddressSanitizer:DEADLYSIGNAL
  [  DEATH   ] =================================================================
  [  DEATH   ] ==178637==ERROR: AddressSanitizer: stack-overflow on address ...

PiperOrigin-RevId: 278709790

Reviewers: pcc

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70332

Added: 
    

Modified: 
    llvm/utils/unittest/googletest/src/gtest-death-test.cc

Removed: 
    


################################################################################
diff  --git a/llvm/utils/unittest/googletest/src/gtest-death-test.cc b/llvm/utils/unittest/googletest/src/gtest-death-test.cc
index a01a36983087..cb8a836e1421 100644
--- a/llvm/utils/unittest/googletest/src/gtest-death-test.cc
+++ b/llvm/utils/unittest/googletest/src/gtest-death-test.cc
@@ -1070,7 +1070,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
 
   if (!use_fork) {
     static const bool stack_grows_down = StackGrowsDown();
-    const size_t stack_size = getpagesize();
+    const size_t stack_size = getpagesize() * 2;
     // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
     void* const stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE,
                              MAP_ANON | MAP_PRIVATE, -1, 0);


        


More information about the llvm-commits mailing list