Skip to content

Commit

Permalink
mac-arm64: Set expectations for tests that crash via __builtin_trap
Browse files Browse the repository at this point in the history
__builtin_trap uses ud2 on x86_64, producing a SIGILL. On arm64, it uses
brk #1, producing a SIGTRAP. Test expectations must be adjusted
accordingly.

Bug: crashpad:345
Test: crashpad_snapshot_test MachOImageAnnotationsReader.CrashModuleInitialization, crashpad_util_test ExcServerVariants.*,ExceptionPorts.*
Change-Id: I22e75b7b48b8887031b1d95f1cea8a09733daf49
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2386464
Commit-Queue: Mark Mentovai <[email protected]>
Reviewed-by: Robert Sesek <[email protected]>
  • Loading branch information
markmentovai authored and Commit Bot committed Sep 4, 2020
1 parent e0d8a0a commit abfc89b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 1 addition & 3 deletions snapshot/mac/mach_o_image_annotations_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ class TestMachOImageAnnotationsReader final
break;

case kCrashModuleInitialization:
// This crash is triggered by __builtin_trap(), which shows up as
// SIGILL.
SetExpectedChildTermination(kTerminationSignal, SIGILL);
SetExpectedChildTerminationBuiltinTrap();
break;

case kCrashDyld:
Expand Down
3 changes: 1 addition & 2 deletions util/mach/exc_server_variants_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -975,8 +975,7 @@ class TestExcServerVariants : public MachMultiprocess,
flavor_(flavor),
state_count_(state_count),
handled_(false) {
// This is how the __builtin_trap() in MachMultiprocessChild() appears.
SetExpectedChildTermination(kTerminationSignal, SIGILL);
SetExpectedChildTerminationBuiltinTrap();
}

// UniversalMachExcServer::Interface:
Expand Down
14 changes: 10 additions & 4 deletions util/mach/exception_ports_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "base/macros.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "test/mac/mach_errors.h"
#include "test/mac/mach_multiprocess.h"
Expand Down Expand Up @@ -145,8 +146,7 @@ class TestExceptionPorts : public MachMultiprocess,
who_crashes_(who_crashes),
handled_(false) {
if (who_crashes_ != kNobodyCrashes) {
// This is how the __builtin_trap() in Child::Crash() appears.
SetExpectedChildTermination(kTerminationSignal, SIGILL);
SetExpectedChildTerminationBuiltinTrap();
}
}

Expand Down Expand Up @@ -205,8 +205,14 @@ class TestExceptionPorts : public MachMultiprocess,
int signal;
ExcCrashRecoverOriginalException(code[0], nullptr, &signal);

// The child crashed with __builtin_trap(), which shows up as SIGILL.
EXPECT_EQ(signal, SIGILL);
#if defined(ARCH_CPU_X86_FAMILY)
constexpr int kBuiltinTrapSignal = SIGILL;
#elif defined(ARCH_CPU_ARM64)
constexpr int kBuiltinTrapSignal = SIGTRAP;
#else
#error Port
#endif
EXPECT_EQ(signal, kBuiltinTrapSignal);
}

EXPECT_EQ(AuditPIDFromMachMessageTrailer(trailer), 0);
Expand Down

0 comments on commit abfc89b

Please sign in to comment.