[PATCH] D70332: Cherry-pick gtest fix for asan tests.
Evgenii Stepanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 15 11:34:55 PST 2019
eugenis created this revision.
eugenis added a reviewer: pcc.
Herald added a project: LLVM.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70332
Files:
llvm/utils/unittest/googletest/src/gtest-death-test.cc
Index: llvm/utils/unittest/googletest/src/gtest-death-test.cc
===================================================================
--- llvm/utils/unittest/googletest/src/gtest-death-test.cc
+++ llvm/utils/unittest/googletest/src/gtest-death-test.cc
@@ -1070,7 +1070,7 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70332.229607.patch
Type: text/x-patch
Size: 656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191115/3070b4f2/attachment-0001.bin>
More information about the llvm-commits
mailing list