linux: fix alt-stack tests with asan

Disable the stack-overrun test since ASAN will detect the
stack corruption and kill the process.

Also allocate extra alt-stack space when ASAN is enabled.

Change-Id: Id8711d2aaa31c90c78b7feceec2877c18dc9be00
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2303591
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Joshua Peraza 2020-07-20 13:29:44 -07:00 committed by Commit Bot
parent 9f66d569fb
commit 070b18d326
2 changed files with 16 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#include "util/linux/scoped_pr_set_dumpable.h"
#include "util/linux/scoped_pr_set_ptracer.h"
#include "util/linux/socket.h"
#include "util/misc/address_sanitizer.h"
#include "util/misc/from_pointer_cast.h"
#include "util/posix/double_fork_and_exec.h"
#include "util/posix/scoped_mmap.h"
@ -433,7 +434,11 @@ bool CrashpadClient::InitializeSignalStackForThread() {
DCHECK_EQ(stack.ss_flags & SS_ONSTACK, 0);
const size_t page_size = getpagesize();
#if defined(ADDRESS_SANITIZER)
const size_t kStackSize = 2 * ((SIGSTKSZ + page_size - 1) & ~(page_size - 1));
#else
const size_t kStackSize = (SIGSTKSZ + page_size - 1) & ~(page_size - 1);
#endif // ADDRESS_SANITIZER
if (stack.ss_flags & SS_DISABLE || stack.ss_size < kStackSize) {
const size_t kGuardPageSize = page_size;
const size_t kStackAllocSize = kStackSize + 2 * kGuardPageSize;
@ -441,7 +446,12 @@ bool CrashpadClient::InitializeSignalStackForThread() {
static void (*stack_destructor)(void*) = [](void* stack_mem) {
const size_t page_size = getpagesize();
const size_t kGuardPageSize = page_size;
#if defined(ADDRESS_SANITIZER)
const size_t kStackSize =
2 * ((SIGSTKSZ + page_size - 1) & ~(page_size - 1));
#else
const size_t kStackSize = (SIGSTKSZ + page_size - 1) & ~(page_size - 1);
#endif // ADDRESS_SANITIZER
const size_t kStackAllocSize = kStackSize + 2 * kGuardPageSize;
stack_t stack;

View File

@ -41,6 +41,7 @@
#include "util/linux/exception_handler_client.h"
#include "util/linux/exception_information.h"
#include "util/linux/socket.h"
#include "util/misc/address_sanitizer.h"
#include "util/misc/address_types.h"
#include "util/misc/from_pointer_cast.h"
#include "util/posix/scoped_mmap.h"
@ -425,6 +426,11 @@ TEST_P(StartHandlerForSelfTest, StartHandlerInChild) {
// TODO(jperaza): test first chance handlers with real crashes.
return;
}
#if defined(ADDRESS_SANITIZER)
if (Options().crash_type == CrashType::kInfiniteRecursion) {
GTEST_SKIP();
}
#endif // defined(ADDRESS_SANITIZER)
StartHandlerForSelfInChildTest test(Options());
test.Run();
}