Bug 1638856 - Increase the stack space passed to the child process to accomodate for its usage. r=gbrown, a=test-only
authorGabriele Svelto <gsvelto@mozilla.com>
Tue, 30 Jun 2020 08:49:00 +0000
changeset 601886 5882e2762533b6448ea12551b19561ade4d96657
parent 601885 8b5806c7ae8eb307fbc5ffd92fee1e3d9b53fc10
child 601887 9db3d5cb8008c0507e2507da8ff3409fc2e52e91
push id13341
push userryanvm@gmail.com
push dateThu, 02 Jul 2020 15:55:10 +0000
treeherdermozilla-beta@a0161364227e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown, test-only
bugs1638856
milestone79.0
Bug 1638856 - Increase the stack space passed to the child process to accomodate for its usage. r=gbrown, a=test-only Differential Revision: https://phabricator.services.mozilla.com/D81372
testing/gtest/gtest/src/gtest-death-test.cc
testing/gtest/mozilla-changes.diff
--- a/testing/gtest/gtest/src/gtest-death-test.cc
+++ b/testing/gtest/gtest/src/gtest-death-test.cc
@@ -1281,17 +1281,17 @@ static pid_t ExecDeathTestSpawnChild(cha
       SIGPROF, &ignore_sigprof_action, &saved_sigprof_action));
 #   endif  // GTEST_OS_LINUX
 
 #   if GTEST_HAS_CLONE
   const bool use_fork = GTEST_FLAG(death_test_use_fork);
 
   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);
     GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);
 
     // Maximum stack alignment in bytes:  For a downward-growing stack, this
     // amount is subtracted from size of the stack space to get an address
     // that is within the stack space and is aligned on all systems we care
--- a/testing/gtest/mozilla-changes.diff
+++ b/testing/gtest/mozilla-changes.diff
@@ -32,16 +32,27 @@ diff --git a/gtest/src/gtest-death-test.
  // Some POSIX platforms expect you to declare environ. extern "C" makes
  // it reside in the global namespace.
 -extern "C" char** environ;
 +extern "C" __attribute__ ((visibility ("default"))) char** environ;
  inline char** GetEnviron() { return environ; }
  #  endif  // GTEST_OS_MAC
  
  #  if !GTEST_OS_QNX
+@@ -1285,9 +1285,9 @@ static pid_t ExecDeathTestSpawnChild(cha
+   const bool use_fork = GTEST_FLAG(death_test_use_fork);
+ 
+   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);
+     GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);
 diff --git a/gtest/src/gtest.cc b/gtest/src/gtest.cc
 --- a/gtest/src/gtest.cc
 +++ b/gtest/src/gtest.cc
 @@ -33,8 +33,10 @@
  #include "gtest/gtest.h"
  #include "gtest/internal/custom/gtest.h"
  #include "gtest/gtest-spi.h"