dev-cpp/gtest: Fix segfault in googletest-death-test
authorPeter Levine <plevine457@gmail.com>
Sun, 16 Jun 2019 23:55:31 +0000 (19:55 -0400)
committerMichał Górny <mgorny@gentoo.org>
Mon, 17 Jun 2019 06:25:05 +0000 (08:25 +0200)
Fixes call to mmap to include MAP_GROWSDOWN flag for
stack auto-resizing.

Reported-by: tka <tka@kamph.org>
Tested-by: Arfrever Frehtes Taifersar Arahesis <arfrever.fta@gmail.com>
Closes: https://bugs.gentoo.org/688162
Closes: https://github.com/gentoo/gentoo/pull/12271
Package-Manager: Portage-2.3.67, Repoman-2.3.14
Signed-off-by: Peter Levine <plevine457@gmail.com>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
dev-cpp/gtest/files/gtest-1.9.0_pre20190607-add-mmap-stack-flag.patch [new file with mode: 0644]
dev-cpp/gtest/files/gtest-9999-increase-clone-stack-size.patch [deleted file]
dev-cpp/gtest/gtest-1.7.0-r1.ebuild
dev-cpp/gtest/gtest-1.8.0-r1.ebuild
dev-cpp/gtest/gtest-1.8.0.ebuild
dev-cpp/gtest/gtest-1.9.0_pre20190607.ebuild
dev-cpp/gtest/gtest-9999.ebuild

diff --git a/dev-cpp/gtest/files/gtest-1.9.0_pre20190607-add-mmap-stack-flag.patch b/dev-cpp/gtest/files/gtest-1.9.0_pre20190607-add-mmap-stack-flag.patch
new file mode 100644 (file)
index 0000000..9a840aa
--- /dev/null
@@ -0,0 +1,15 @@
+Bug: https://bugs.gentoo.org/688162
+Upstream PR: https://github.com/google/googletest/pull/2276
+
+--- a/googletest/src/gtest-death-test.cc
++++ b/googletest/src/gtest-death-test.cc
+@@ -1357,6 +1357,9 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
+     const auto stack_size = static_cast<size_t>(getpagesize());
+     // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
+     void* const stack = mmap(nullptr, stack_size, PROT_READ | PROT_WRITE,
++#    if GTEST_OS_LINUX
++                             (stack_grows_down ? MAP_GROWSDOWN : 0) | // Needed for stack auto-resizing
++#    endif
+                              MAP_ANON | MAP_PRIVATE, -1, 0);
+     GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);
diff --git a/dev-cpp/gtest/files/gtest-9999-increase-clone-stack-size.patch b/dev-cpp/gtest/files/gtest-9999-increase-clone-stack-size.patch
deleted file mode 100644 (file)
index 5e4dc47..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-Bug: https://bugs.gentoo.org/629620
-Upstream PR: https://github.com/google/googletest/pull/2276
-
---- a/googletest/src/gtest-death-test.cc
-+++ b/googletest/src/gtest-death-test.cc
-@@ -1354,7 +1354,7 @@
-
-   if (!use_fork) {
-     static const bool stack_grows_down = StackGrowsDown();
--    const auto stack_size = static_cast<size_t>(getpagesize());
-+    const auto stack_size = static_cast<size_t>(getpagesize() * 8);
-     // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
-     void* const stack = mmap(nullptr, stack_size, PROT_READ | PROT_WRITE,
-                              MAP_ANON | MAP_PRIVATE, -1, 0);
index f1185b2db0cc5d34a32a991e8d6186944e1485b3..360809f62e74c9e5109023f5f1ca69c3235f4e27 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI="5"
index 18d837c58fcd29c4ac4f0034433122134087822d..0e0934020cdb48a3d24444e53a789de51b51eddf 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
index a2fc61eb5c4f67b4aaadc467c57e2913461dbb70..da82dca28b27ed071dd548041eef6fdb8a9acb97 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
index 1ff88fb723ff742b7a7d4e0db1d883a457b59c7a..9fc545d7fd83a42719cca608c369c1e16ee43d2e 100644 (file)
@@ -35,7 +35,7 @@ DEPEND="test? ( ${PYTHON_DEPS} )"
 RDEPEND="!dev-cpp/gmock"
 
 PATCHES=(
-       "${FILESDIR}"/${PN}-9999-increase-clone-stack-size.patch
+       "${FILESDIR}"/${PN}-1.9.0_pre20190607-add-mmap-stack-flag.patch
 )
 
 pkg_setup() {
index 685acf50cd6769986cd55bc02b183ad470b58b41..bd677dc0bd1db674df9fcd5be8e3258cce01104b 100644 (file)
@@ -33,7 +33,7 @@ DEPEND="test? ( ${PYTHON_DEPS} )"
 RDEPEND="!dev-cpp/gmock"
 
 PATCHES=(
-       "${FILESDIR}"/${PN}-9999-increase-clone-stack-size.patch
+       "${FILESDIR}"/${PN}-1.9.0_pre20190607-add-mmap-stack-flag.patch
 )
 
 pkg_setup() {