mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-25 22:30:49 +08:00
Fix ASan failures for MinidumpCrashpadInfoWriter
Fuchsia AddressSanitizer tests were failing because of unaligned memory access in several unit tests. Fixed: fuchsia:125877 Change-Id: If577ea9b7be24ef40865a637d8f6b6d94daaeb67 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4510016 Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
parent
a280d65971
commit
3307c7cefc
@ -148,8 +148,17 @@ TEST(MinidumpCrashpadInfoWriter, AddressMask) {
|
||||
ASSERT_TRUE(empty_client_id.InitializeFromString(
|
||||
"00000000-0000-0000-0000-000000000000"));
|
||||
|
||||
// Copy address_mask into a local variable because
|
||||
// |MinidumpCrashpadInfo::address_mask| requires 8-byte alignment but the
|
||||
// struct itself is 4-byte aligned.
|
||||
const auto address_mask = [&crashpad_info] {
|
||||
uint64_t data = 0;
|
||||
memcpy(&data, &crashpad_info->address_mask, sizeof(data));
|
||||
return data;
|
||||
}();
|
||||
|
||||
EXPECT_EQ(crashpad_info->version, MinidumpCrashpadInfo::kVersion);
|
||||
EXPECT_EQ(crashpad_info->address_mask, mask);
|
||||
EXPECT_EQ(address_mask, mask);
|
||||
EXPECT_EQ(crashpad_info->report_id, empty_report_id);
|
||||
EXPECT_EQ(crashpad_info->client_id, empty_client_id);
|
||||
EXPECT_FALSE(simple_annotations);
|
||||
@ -172,7 +181,16 @@ TEST(MinidumpCrashpadInfoWriter, EmptyAddressMask) {
|
||||
ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
|
||||
string_file.string(), &crashpad_info, &simple_annotations, &module_list));
|
||||
|
||||
EXPECT_EQ(crashpad_info->address_mask, 0UL);
|
||||
// Copy address_mask into a local variable because
|
||||
// |MinidumpCrashpadInfo::address_mask| requires 8-byte alignment but the
|
||||
// struct itself is 4-byte aligned.
|
||||
const auto address_mask = [&crashpad_info] {
|
||||
uint64_t data = 0;
|
||||
memcpy(&data, &crashpad_info->address_mask, sizeof(data));
|
||||
return data;
|
||||
}();
|
||||
|
||||
EXPECT_EQ(address_mask, 0UL);
|
||||
}
|
||||
|
||||
TEST(MinidumpCrashpadInfoWriter, SimpleAnnotations) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user