Skip to content

Commit

Permalink
GWP-ASan: Add Linux crash handler support
Browse files Browse the repository at this point in the history
Linux crashpad support is now sufficiently enabled to allow running the
GWP-ASan crash handler unit tests under Linux. (The client tests are
still blocked on allocator shim updates.)

Change-Id: I409cebaa9cdaed5da546266d0af470d2b25a09ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1610605
Auto-Submit: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659296}
  • Loading branch information
vlad902 authored and Commit Bot committed May 14, 2019
1 parent 949d549 commit 7003473
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
8 changes: 4 additions & 4 deletions components/gwp_asan/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ source_set("unit_tests") {
"//components/gwp_asan/common:unit_tests",
]
if (is_win || is_mac) {
deps += [
"//components/gwp_asan/client:unit_tests",
"//components/gwp_asan/crash_handler:unit_tests",
]
deps += [ "//components/gwp_asan/client:unit_tests" ]
}
if (is_win || is_mac || is_linux) {
deps += [ "//components/gwp_asan/crash_handler:unit_tests" ]
}
}
1 change: 1 addition & 0 deletions components/gwp_asan/crash_handler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ static_library("crash_handler") {
sources = [
"crash_analyzer.cc",
"crash_analyzer.h",
"crash_analyzer_linux.cc",
"crash_analyzer_mac.cc",
"crash_analyzer_win.cc",
"crash_handler.cc",
Expand Down
23 changes: 23 additions & 0 deletions components/gwp_asan/crash_handler/crash_analyzer_linux.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/gwp_asan/crash_handler/crash_analyzer.h"

#include <signal.h>

#include "third_party/crashpad/crashpad/snapshot/exception_snapshot.h"

namespace gwp_asan {
namespace internal {

crashpad::VMAddress CrashAnalyzer::GetAccessAddress(
const crashpad::ExceptionSnapshot& exception) {
if (exception.Exception() != SIGSEGV && exception.Exception() != SIGBUS)
return 0;

return exception.ExceptionAddress();
}

} // namespace internal
} // namespace gwp_asan
6 changes: 4 additions & 2 deletions components/gwp_asan/crash_handler/crash_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,15 @@ class CrashHandlerTest : public base::MultiProcessTest,

EXPECT_TRUE(proto_.has_allocation());
EXPECT_TRUE(proto_.allocation().has_thread_id());
EXPECT_NE(proto_.allocation().thread_id(), base::kInvalidThreadId);
EXPECT_NE(proto_.allocation().thread_id(),
static_cast<uint64_t>(base::kInvalidThreadId));
EXPECT_GT(proto_.allocation().stack_trace_size(), 0);

EXPECT_EQ(proto_.has_deallocation(), has_deallocation);
if (has_deallocation) {
EXPECT_TRUE(proto_.deallocation().has_thread_id());
EXPECT_NE(proto_.deallocation().thread_id(), base::kInvalidThreadId);
EXPECT_NE(proto_.deallocation().thread_id(),
static_cast<uint64_t>(base::kInvalidThreadId));
EXPECT_EQ(proto_.allocation().thread_id(),
proto_.deallocation().thread_id());
EXPECT_GT(proto_.deallocation().stack_trace_size(), 0);
Expand Down

0 comments on commit 7003473

Please sign in to comment.