Skip to content

Commit 681454d

Browse files
Abseil TeamXiaoyi Zhang
authored andcommitted
Googletest export
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
1 parent e08a460 commit 681454d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

googletest/src/gtest-death-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
13641364

13651365
if (!use_fork) {
13661366
static const bool stack_grows_down = StackGrowsDown();
1367-
const auto stack_size = static_cast<size_t>(getpagesize());
1367+
const auto stack_size = static_cast<size_t>(getpagesize() * 2);
13681368
// MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
13691369
void* const stack = mmap(nullptr, stack_size, PROT_READ | PROT_WRITE,
13701370
MAP_ANON | MAP_PRIVATE, -1, 0);

0 commit comments

Comments
 (0)