mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Fix instances of undefined behavior
This change removes several unaligned accesses, as well a null pointer offset and an out of bounds array access. Bug: fuchsia:46805 Change-Id: I0110d0b7faf672655d978894b868760eee7b2988 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2583025 Commit-Queue: Scott Graham <scottmg@chromium.org> Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
2f7d40c405
commit
44de18ca37
13
BUILD.gn
13
BUILD.gn
@ -20,19 +20,6 @@ config("crashpad_config") {
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
|
||||
# TODO(fuchsia:46805): Remove this once instances of UB have been cleaned up.
|
||||
config("disable_ubsan") {
|
||||
if (crashpad_is_in_fuchsia) {
|
||||
cflags = [ "-fno-sanitize=undefined" ]
|
||||
}
|
||||
visibility = [
|
||||
"snapshot:snapshot",
|
||||
"minidump:minidump_test",
|
||||
"third_party/googletest:googletest",
|
||||
"util:util",
|
||||
]
|
||||
}
|
||||
|
||||
if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) {
|
||||
test("crashpad_tests") {
|
||||
deps = [
|
||||
|
@ -186,6 +186,4 @@ source_set("minidump_test") {
|
||||
if (crashpad_is_win) {
|
||||
cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union
|
||||
}
|
||||
|
||||
configs += [ "..:disable_ubsan" ]
|
||||
}
|
||||
|
@ -69,22 +69,27 @@ void ExpectExceptionStream(const MINIDUMP_EXCEPTION_STREAM* expected,
|
||||
const MinidumpContextX86** context) {
|
||||
EXPECT_EQ(observed->ThreadId, expected->ThreadId);
|
||||
EXPECT_EQ(observed->__alignment, 0u);
|
||||
EXPECT_EQ(observed->ExceptionRecord.ExceptionCode,
|
||||
expected->ExceptionRecord.ExceptionCode);
|
||||
EXPECT_EQ(observed->ExceptionRecord.ExceptionFlags,
|
||||
expected->ExceptionRecord.ExceptionFlags);
|
||||
EXPECT_EQ(observed->ExceptionRecord.ExceptionRecord,
|
||||
expected->ExceptionRecord.ExceptionRecord);
|
||||
EXPECT_EQ(observed->ExceptionRecord.ExceptionAddress,
|
||||
expected->ExceptionRecord.ExceptionAddress);
|
||||
EXPECT_EQ(observed->ExceptionRecord.NumberParameters,
|
||||
expected->ExceptionRecord.NumberParameters);
|
||||
|
||||
// Copy the ExceptionRecords so that their uint64_t members can be accessed
|
||||
// with the proper alignment.
|
||||
const MINIDUMP_EXCEPTION observed_exception = observed->ExceptionRecord;
|
||||
const MINIDUMP_EXCEPTION expected_exception = expected->ExceptionRecord;
|
||||
|
||||
EXPECT_EQ(observed_exception.ExceptionCode, expected_exception.ExceptionCode);
|
||||
EXPECT_EQ(observed_exception.ExceptionFlags,
|
||||
expected_exception.ExceptionFlags);
|
||||
EXPECT_EQ(observed_exception.ExceptionRecord,
|
||||
expected_exception.ExceptionRecord);
|
||||
EXPECT_EQ(observed_exception.ExceptionAddress,
|
||||
expected_exception.ExceptionAddress);
|
||||
EXPECT_EQ(observed_exception.NumberParameters,
|
||||
expected_exception.NumberParameters);
|
||||
EXPECT_EQ(observed->ExceptionRecord.__unusedAlignment, 0u);
|
||||
for (size_t index = 0;
|
||||
index < base::size(observed->ExceptionRecord.ExceptionInformation);
|
||||
index < base::size(observed_exception.ExceptionInformation);
|
||||
++index) {
|
||||
EXPECT_EQ(observed->ExceptionRecord.ExceptionInformation[index],
|
||||
expected->ExceptionRecord.ExceptionInformation[index]);
|
||||
EXPECT_EQ(observed_exception.ExceptionInformation[index],
|
||||
expected_exception.ExceptionInformation[index]);
|
||||
}
|
||||
*context = MinidumpWritableAtLocationDescriptor<MinidumpContextX86>(
|
||||
file_contents, observed->ThreadContext);
|
||||
|
@ -110,18 +110,17 @@ TEST(MinidumpHandleDataWriter, OneHandle) {
|
||||
GetHandleDataStream(string_file.string(), &handle_data_stream));
|
||||
|
||||
EXPECT_EQ(handle_data_stream->NumberOfDescriptors, 1u);
|
||||
const MINIDUMP_HANDLE_DESCRIPTOR* handle_descriptor =
|
||||
reinterpret_cast<const MINIDUMP_HANDLE_DESCRIPTOR*>(
|
||||
&handle_data_stream[1]);
|
||||
EXPECT_EQ(handle_descriptor->Handle, handle_snapshot.handle);
|
||||
MINIDUMP_HANDLE_DESCRIPTOR handle_descriptor;
|
||||
memcpy(&handle_descriptor, &handle_data_stream[1], sizeof(handle_descriptor));
|
||||
EXPECT_EQ(handle_descriptor.Handle, handle_snapshot.handle);
|
||||
EXPECT_EQ(base::UTF16ToUTF8(MinidumpStringAtRVAAsString(
|
||||
string_file.string(), handle_descriptor->TypeNameRva)),
|
||||
string_file.string(), handle_descriptor.TypeNameRva)),
|
||||
handle_snapshot.type_name);
|
||||
EXPECT_EQ(handle_descriptor->ObjectNameRva, 0u);
|
||||
EXPECT_EQ(handle_descriptor->Attributes, handle_snapshot.attributes);
|
||||
EXPECT_EQ(handle_descriptor->GrantedAccess, handle_snapshot.granted_access);
|
||||
EXPECT_EQ(handle_descriptor->HandleCount, handle_snapshot.handle_count);
|
||||
EXPECT_EQ(handle_descriptor->PointerCount, handle_snapshot.pointer_count);
|
||||
EXPECT_EQ(handle_descriptor.ObjectNameRva, 0u);
|
||||
EXPECT_EQ(handle_descriptor.Attributes, handle_snapshot.attributes);
|
||||
EXPECT_EQ(handle_descriptor.GrantedAccess, handle_snapshot.granted_access);
|
||||
EXPECT_EQ(handle_descriptor.HandleCount, handle_snapshot.handle_count);
|
||||
EXPECT_EQ(handle_descriptor.PointerCount, handle_snapshot.pointer_count);
|
||||
}
|
||||
|
||||
TEST(MinidumpHandleDataWriter, RepeatedTypeName) {
|
||||
@ -168,34 +167,34 @@ TEST(MinidumpHandleDataWriter, RepeatedTypeName) {
|
||||
GetHandleDataStream(string_file.string(), &handle_data_stream));
|
||||
|
||||
EXPECT_EQ(handle_data_stream->NumberOfDescriptors, 2u);
|
||||
const MINIDUMP_HANDLE_DESCRIPTOR* handle_descriptor =
|
||||
reinterpret_cast<const MINIDUMP_HANDLE_DESCRIPTOR*>(
|
||||
&handle_data_stream[1]);
|
||||
EXPECT_EQ(handle_descriptor->Handle, handle_snapshot.handle);
|
||||
MINIDUMP_HANDLE_DESCRIPTOR handle_descriptor;
|
||||
memcpy(&handle_descriptor, &handle_data_stream[1], sizeof(handle_descriptor));
|
||||
EXPECT_EQ(handle_descriptor.Handle, handle_snapshot.handle);
|
||||
EXPECT_EQ(base::UTF16ToUTF8(MinidumpStringAtRVAAsString(
|
||||
string_file.string(), handle_descriptor->TypeNameRva)),
|
||||
string_file.string(), handle_descriptor.TypeNameRva)),
|
||||
handle_snapshot.type_name);
|
||||
EXPECT_EQ(handle_descriptor->ObjectNameRva, 0u);
|
||||
EXPECT_EQ(handle_descriptor->Attributes, handle_snapshot.attributes);
|
||||
EXPECT_EQ(handle_descriptor->GrantedAccess, handle_snapshot.granted_access);
|
||||
EXPECT_EQ(handle_descriptor->HandleCount, handle_snapshot.handle_count);
|
||||
EXPECT_EQ(handle_descriptor->PointerCount, handle_snapshot.pointer_count);
|
||||
EXPECT_EQ(handle_descriptor.ObjectNameRva, 0u);
|
||||
EXPECT_EQ(handle_descriptor.Attributes, handle_snapshot.attributes);
|
||||
EXPECT_EQ(handle_descriptor.GrantedAccess, handle_snapshot.granted_access);
|
||||
EXPECT_EQ(handle_descriptor.HandleCount, handle_snapshot.handle_count);
|
||||
EXPECT_EQ(handle_descriptor.PointerCount, handle_snapshot.pointer_count);
|
||||
|
||||
const MINIDUMP_HANDLE_DESCRIPTOR* handle_descriptor2 =
|
||||
reinterpret_cast<const MINIDUMP_HANDLE_DESCRIPTOR*>(
|
||||
reinterpret_cast<const unsigned char*>(&handle_data_stream[1]) +
|
||||
sizeof(MINIDUMP_HANDLE_DESCRIPTOR));
|
||||
EXPECT_EQ(handle_descriptor2->Handle, handle_snapshot2.handle);
|
||||
MINIDUMP_HANDLE_DESCRIPTOR handle_descriptor2;
|
||||
memcpy(&handle_descriptor2,
|
||||
reinterpret_cast<const unsigned char*>(&handle_data_stream[1]) +
|
||||
sizeof(MINIDUMP_HANDLE_DESCRIPTOR),
|
||||
sizeof(handle_descriptor2));
|
||||
EXPECT_EQ(handle_descriptor2.Handle, handle_snapshot2.handle);
|
||||
EXPECT_EQ(base::UTF16ToUTF8(MinidumpStringAtRVAAsString(
|
||||
string_file.string(), handle_descriptor2->TypeNameRva)),
|
||||
string_file.string(), handle_descriptor2.TypeNameRva)),
|
||||
handle_snapshot2.type_name);
|
||||
EXPECT_EQ(handle_descriptor2->ObjectNameRva, 0u);
|
||||
EXPECT_EQ(handle_descriptor2->Attributes, handle_snapshot2.attributes);
|
||||
EXPECT_EQ(handle_descriptor2->GrantedAccess, handle_snapshot2.granted_access);
|
||||
EXPECT_EQ(handle_descriptor2->HandleCount, handle_snapshot2.handle_count);
|
||||
EXPECT_EQ(handle_descriptor2->PointerCount, handle_snapshot2.pointer_count);
|
||||
EXPECT_EQ(handle_descriptor2.ObjectNameRva, 0u);
|
||||
EXPECT_EQ(handle_descriptor2.Attributes, handle_snapshot2.attributes);
|
||||
EXPECT_EQ(handle_descriptor2.GrantedAccess, handle_snapshot2.granted_access);
|
||||
EXPECT_EQ(handle_descriptor2.HandleCount, handle_snapshot2.handle_count);
|
||||
EXPECT_EQ(handle_descriptor2.PointerCount, handle_snapshot2.pointer_count);
|
||||
|
||||
EXPECT_EQ(handle_descriptor2->TypeNameRva, handle_descriptor->TypeNameRva);
|
||||
EXPECT_EQ(handle_descriptor2.TypeNameRva, handle_descriptor.TypeNameRva);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -74,7 +74,11 @@ TEST(MinidumpMemoryInfoWriter, Empty) {
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
GetMemoryInfoListStream(string_file.string(), &memory_info_list));
|
||||
|
||||
EXPECT_EQ(memory_info_list->NumberOfEntries, 0u);
|
||||
uint64_t number_of_entries;
|
||||
memcpy(&number_of_entries,
|
||||
&memory_info_list->NumberOfEntries,
|
||||
sizeof(number_of_entries));
|
||||
EXPECT_EQ(number_of_entries, 0u);
|
||||
}
|
||||
|
||||
TEST(MinidumpMemoryInfoWriter, OneRegion) {
|
||||
@ -115,16 +119,21 @@ TEST(MinidumpMemoryInfoWriter, OneRegion) {
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
GetMemoryInfoListStream(string_file.string(), &memory_info_list));
|
||||
|
||||
EXPECT_EQ(memory_info_list->NumberOfEntries, 1u);
|
||||
const MINIDUMP_MEMORY_INFO* memory_info =
|
||||
reinterpret_cast<const MINIDUMP_MEMORY_INFO*>(&memory_info_list[1]);
|
||||
EXPECT_EQ(memory_info->BaseAddress, mmi.BaseAddress);
|
||||
EXPECT_EQ(memory_info->AllocationBase, mmi.AllocationBase);
|
||||
EXPECT_EQ(memory_info->AllocationProtect, mmi.AllocationProtect);
|
||||
EXPECT_EQ(memory_info->RegionSize, mmi.RegionSize);
|
||||
EXPECT_EQ(memory_info->State, mmi.State);
|
||||
EXPECT_EQ(memory_info->Protect, mmi.Protect);
|
||||
EXPECT_EQ(memory_info->Type, mmi.Type);
|
||||
uint64_t number_of_entries;
|
||||
memcpy(&number_of_entries,
|
||||
&memory_info_list->NumberOfEntries,
|
||||
sizeof(number_of_entries));
|
||||
EXPECT_EQ(number_of_entries, 1u);
|
||||
|
||||
MINIDUMP_MEMORY_INFO memory_info;
|
||||
memcpy(&memory_info, &memory_info_list[1], sizeof(memory_info));
|
||||
EXPECT_EQ(memory_info.BaseAddress, mmi.BaseAddress);
|
||||
EXPECT_EQ(memory_info.AllocationBase, mmi.AllocationBase);
|
||||
EXPECT_EQ(memory_info.AllocationProtect, mmi.AllocationProtect);
|
||||
EXPECT_EQ(memory_info.RegionSize, mmi.RegionSize);
|
||||
EXPECT_EQ(memory_info.State, mmi.State);
|
||||
EXPECT_EQ(memory_info.Protect, mmi.Protect);
|
||||
EXPECT_EQ(memory_info.Type, mmi.Type);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -171,20 +171,27 @@ void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_5>(
|
||||
ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_4>(
|
||||
reinterpret_cast<const MINIDUMP_MISC_INFO_4*>(expected),
|
||||
reinterpret_cast<const MINIDUMP_MISC_INFO_4*>(observed));
|
||||
EXPECT_EQ(observed->XStateData.SizeOfInfo, expected->XStateData.SizeOfInfo);
|
||||
EXPECT_EQ(observed->XStateData.ContextSize, expected->XStateData.ContextSize);
|
||||
EXPECT_EQ(observed->XStateData.EnabledFeatures,
|
||||
expected->XStateData.EnabledFeatures);
|
||||
|
||||
MINIDUMP_MISC_INFO_5 expected_misc_info, observed_misc_info;
|
||||
memcpy(&expected_misc_info, expected, sizeof(expected_misc_info));
|
||||
memcpy(&observed_misc_info, observed, sizeof(observed_misc_info));
|
||||
|
||||
EXPECT_EQ(observed_misc_info.XStateData.SizeOfInfo,
|
||||
expected_misc_info.XStateData.SizeOfInfo);
|
||||
EXPECT_EQ(observed_misc_info.XStateData.ContextSize,
|
||||
expected_misc_info.XStateData.ContextSize);
|
||||
EXPECT_EQ(observed_misc_info.XStateData.EnabledFeatures,
|
||||
expected_misc_info.XStateData.EnabledFeatures);
|
||||
for (size_t feature_index = 0;
|
||||
feature_index < base::size(observed->XStateData.Features);
|
||||
feature_index < base::size(observed_misc_info.XStateData.Features);
|
||||
++feature_index) {
|
||||
SCOPED_TRACE(base::StringPrintf("feature_index %" PRIuS, feature_index));
|
||||
EXPECT_EQ(observed->XStateData.Features[feature_index].Offset,
|
||||
expected->XStateData.Features[feature_index].Offset);
|
||||
EXPECT_EQ(observed->XStateData.Features[feature_index].Size,
|
||||
expected->XStateData.Features[feature_index].Size);
|
||||
EXPECT_EQ(observed_misc_info.XStateData.Features[feature_index].Offset,
|
||||
expected_misc_info.XStateData.Features[feature_index].Offset);
|
||||
EXPECT_EQ(observed_misc_info.XStateData.Features[feature_index].Size,
|
||||
expected_misc_info.XStateData.Features[feature_index].Size);
|
||||
}
|
||||
EXPECT_EQ(observed->ProcessCookie, expected->ProcessCookie);
|
||||
EXPECT_EQ(observed_misc_info.ProcessCookie, expected_misc_info.ProcessCookie);
|
||||
}
|
||||
|
||||
TEST(MinidumpMiscInfoWriter, Empty) {
|
||||
|
@ -213,56 +213,68 @@ void ExpectModule(const MINIDUMP_MODULE* expected,
|
||||
const char* expected_debug_name,
|
||||
uint32_t expected_debug_type,
|
||||
bool expected_debug_utf16) {
|
||||
EXPECT_EQ(observed->BaseOfImage, expected->BaseOfImage);
|
||||
EXPECT_EQ(observed->SizeOfImage, expected->SizeOfImage);
|
||||
EXPECT_EQ(observed->CheckSum, expected->CheckSum);
|
||||
EXPECT_EQ(observed->TimeDateStamp, expected->TimeDateStamp);
|
||||
EXPECT_EQ(observed->VersionInfo.dwSignature,
|
||||
implicit_cast<uint32_t>(VS_FFI_SIGNATURE));
|
||||
EXPECT_EQ(observed->VersionInfo.dwStrucVersion,
|
||||
implicit_cast<uint32_t>(VS_FFI_STRUCVERSION));
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileVersionMS,
|
||||
expected->VersionInfo.dwFileVersionMS);
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileVersionLS,
|
||||
expected->VersionInfo.dwFileVersionLS);
|
||||
EXPECT_EQ(observed->VersionInfo.dwProductVersionMS,
|
||||
expected->VersionInfo.dwProductVersionMS);
|
||||
EXPECT_EQ(observed->VersionInfo.dwProductVersionLS,
|
||||
expected->VersionInfo.dwProductVersionLS);
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileFlagsMask,
|
||||
expected->VersionInfo.dwFileFlagsMask);
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileFlags,
|
||||
expected->VersionInfo.dwFileFlags);
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileOS, expected->VersionInfo.dwFileOS);
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileType, expected->VersionInfo.dwFileType);
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileSubtype,
|
||||
expected->VersionInfo.dwFileSubtype);
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileDateMS,
|
||||
expected->VersionInfo.dwFileDateMS);
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileDateLS,
|
||||
expected->VersionInfo.dwFileDateLS);
|
||||
EXPECT_EQ(observed->Reserved0, 0u);
|
||||
EXPECT_EQ(observed->Reserved1, 0u);
|
||||
MINIDUMP_MODULE expected_module, observed_module;
|
||||
memcpy(&expected_module, expected, sizeof(expected_module));
|
||||
memcpy(&observed_module, observed, sizeof(observed_module));
|
||||
|
||||
EXPECT_NE(observed->ModuleNameRva, 0u);
|
||||
EXPECT_EQ(observed_module.BaseOfImage, expected_module.BaseOfImage);
|
||||
EXPECT_EQ(observed_module.SizeOfImage, expected_module.SizeOfImage);
|
||||
EXPECT_EQ(observed_module.CheckSum, expected_module.CheckSum);
|
||||
EXPECT_EQ(observed_module.TimeDateStamp, expected_module.TimeDateStamp);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwSignature,
|
||||
implicit_cast<uint32_t>(VS_FFI_SIGNATURE));
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwStrucVersion,
|
||||
implicit_cast<uint32_t>(VS_FFI_STRUCVERSION));
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwFileVersionMS,
|
||||
expected_module.VersionInfo.dwFileVersionMS);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwFileVersionLS,
|
||||
expected_module.VersionInfo.dwFileVersionLS);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwProductVersionMS,
|
||||
expected_module.VersionInfo.dwProductVersionMS);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwProductVersionLS,
|
||||
expected_module.VersionInfo.dwProductVersionLS);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwFileFlagsMask,
|
||||
expected_module.VersionInfo.dwFileFlagsMask);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwFileFlags,
|
||||
expected_module.VersionInfo.dwFileFlags);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwFileOS,
|
||||
expected_module.VersionInfo.dwFileOS);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwFileType,
|
||||
expected_module.VersionInfo.dwFileType);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwFileSubtype,
|
||||
expected_module.VersionInfo.dwFileSubtype);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwFileDateMS,
|
||||
expected_module.VersionInfo.dwFileDateMS);
|
||||
EXPECT_EQ(observed_module.VersionInfo.dwFileDateLS,
|
||||
expected_module.VersionInfo.dwFileDateLS);
|
||||
|
||||
uint64_t reserved0, reserved1;
|
||||
memcpy(&reserved0, &observed_module.Reserved0, sizeof(reserved0));
|
||||
memcpy(&reserved1, &observed_module.Reserved1, sizeof(reserved1));
|
||||
|
||||
EXPECT_EQ(reserved0, 0u);
|
||||
EXPECT_EQ(reserved1, 0u);
|
||||
|
||||
EXPECT_NE(observed_module.ModuleNameRva, 0u);
|
||||
base::string16 observed_module_name_utf16 =
|
||||
MinidumpStringAtRVAAsString(file_contents, observed->ModuleNameRva);
|
||||
MinidumpStringAtRVAAsString(file_contents, observed_module.ModuleNameRva);
|
||||
base::string16 expected_module_name_utf16 =
|
||||
base::UTF8ToUTF16(expected_module_name);
|
||||
EXPECT_EQ(observed_module_name_utf16, expected_module_name_utf16);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectCodeViewRecord(&observed->CvRecord,
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectCodeViewRecord(&observed_module.CvRecord,
|
||||
file_contents,
|
||||
expected_pdb_name,
|
||||
expected_pdb_uuid,
|
||||
expected_pdb_timestamp,
|
||||
expected_pdb_age));
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectMiscellaneousDebugRecord(&observed->MiscRecord,
|
||||
file_contents,
|
||||
expected_debug_name,
|
||||
expected_debug_type,
|
||||
expected_debug_utf16));
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
ExpectMiscellaneousDebugRecord(&observed_module.MiscRecord,
|
||||
file_contents,
|
||||
expected_debug_name,
|
||||
expected_debug_type,
|
||||
expected_debug_utf16));
|
||||
}
|
||||
|
||||
// ExpectModuleWithBuildIDCv() is like ExpectModule( but expects the module to
|
||||
@ -300,8 +312,13 @@ void ExpectModuleWithBuildIDCv(const MINIDUMP_MODULE* expected,
|
||||
expected->VersionInfo.dwFileDateMS);
|
||||
EXPECT_EQ(observed->VersionInfo.dwFileDateLS,
|
||||
expected->VersionInfo.dwFileDateLS);
|
||||
EXPECT_EQ(observed->Reserved0, 0u);
|
||||
EXPECT_EQ(observed->Reserved1, 0u);
|
||||
|
||||
uint64_t reserved0, reserved1;
|
||||
memcpy(&reserved0, &observed->Reserved0, sizeof(reserved0));
|
||||
memcpy(&reserved1, &observed->Reserved1, sizeof(reserved1));
|
||||
|
||||
EXPECT_EQ(reserved0, 0u);
|
||||
EXPECT_EQ(reserved1, 0u);
|
||||
|
||||
EXPECT_NE(observed->ModuleNameRva, 0u);
|
||||
base::string16 observed_module_name_utf16 =
|
||||
|
@ -109,8 +109,11 @@ TEST(MinidumpSystemInfoWriter, Empty) {
|
||||
EXPECT_EQ(system_info->Cpu.X86CpuInfo.VersionInformation, 0u);
|
||||
EXPECT_EQ(system_info->Cpu.X86CpuInfo.FeatureInformation, 0u);
|
||||
EXPECT_EQ(system_info->Cpu.X86CpuInfo.AMDExtendedCpuFeatures, 0u);
|
||||
EXPECT_EQ(system_info->Cpu.OtherCpuInfo.ProcessorFeatures[0], 0u);
|
||||
EXPECT_EQ(system_info->Cpu.OtherCpuInfo.ProcessorFeatures[1], 0u);
|
||||
|
||||
CPU_INFORMATION other_cpu_info;
|
||||
memcpy(&other_cpu_info, &system_info->Cpu, sizeof(other_cpu_info));
|
||||
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[0], 0u);
|
||||
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[1], 0u);
|
||||
|
||||
EXPECT_EQ(csd_version->Buffer[0], '\0');
|
||||
}
|
||||
@ -234,10 +237,11 @@ TEST(MinidumpSystemInfoWriter, AMD64_Mac) {
|
||||
EXPECT_EQ(system_info->BuildNumber, kOSVersionBuild);
|
||||
EXPECT_EQ(system_info->PlatformId, kOS);
|
||||
EXPECT_EQ(system_info->SuiteMask, 0u);
|
||||
EXPECT_EQ(system_info->Cpu.OtherCpuInfo.ProcessorFeatures[0],
|
||||
kCPUFeatures[0]);
|
||||
EXPECT_EQ(system_info->Cpu.OtherCpuInfo.ProcessorFeatures[1],
|
||||
kCPUFeatures[1]);
|
||||
|
||||
CPU_INFORMATION other_cpu_info;
|
||||
memcpy(&other_cpu_info, &system_info->Cpu, sizeof(other_cpu_info));
|
||||
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[0], kCPUFeatures[0]);
|
||||
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[1], kCPUFeatures[1]);
|
||||
}
|
||||
|
||||
TEST(MinidumpSystemInfoWriter, X86_CPUVendorFromRegisters) {
|
||||
@ -457,9 +461,12 @@ TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_AMD64) {
|
||||
EXPECT_EQ(system_info->BuildNumber, expect_system_info.BuildNumber);
|
||||
EXPECT_EQ(system_info->PlatformId, expect_system_info.PlatformId);
|
||||
EXPECT_EQ(system_info->SuiteMask, expect_system_info.SuiteMask);
|
||||
EXPECT_EQ(system_info->Cpu.OtherCpuInfo.ProcessorFeatures[0],
|
||||
|
||||
CPU_INFORMATION other_cpu_info;
|
||||
memcpy(&other_cpu_info, &system_info->Cpu, sizeof(other_cpu_info));
|
||||
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[0],
|
||||
expect_system_info.Cpu.OtherCpuInfo.ProcessorFeatures[0]);
|
||||
EXPECT_EQ(system_info->Cpu.OtherCpuInfo.ProcessorFeatures[1],
|
||||
EXPECT_EQ(other_cpu_info.OtherCpuInfo.ProcessorFeatures[1],
|
||||
expect_system_info.Cpu.OtherCpuInfo.ProcessorFeatures[1]);
|
||||
|
||||
for (size_t index = 0; index < strlen(kOSVersionBuild); ++index) {
|
||||
|
@ -108,33 +108,41 @@ void ExpectThread(const MINIDUMP_THREAD* expected,
|
||||
const std::string& file_contents,
|
||||
const MINIDUMP_MEMORY_DESCRIPTOR** stack,
|
||||
const void** context_base) {
|
||||
EXPECT_EQ(observed->ThreadId, expected->ThreadId);
|
||||
EXPECT_EQ(observed->SuspendCount, expected->SuspendCount);
|
||||
EXPECT_EQ(observed->PriorityClass, expected->PriorityClass);
|
||||
EXPECT_EQ(observed->Priority, expected->Priority);
|
||||
EXPECT_EQ(observed->Teb, expected->Teb);
|
||||
MINIDUMP_THREAD expected_thread, observed_thread;
|
||||
memcpy(&expected_thread, expected, sizeof(expected_thread));
|
||||
memcpy(&observed_thread, observed, sizeof(observed_thread));
|
||||
|
||||
EXPECT_EQ(observed->Stack.StartOfMemoryRange,
|
||||
expected->Stack.StartOfMemoryRange);
|
||||
EXPECT_EQ(observed->Stack.Memory.DataSize, expected->Stack.Memory.DataSize);
|
||||
EXPECT_EQ(observed_thread.ThreadId, expected_thread.ThreadId);
|
||||
EXPECT_EQ(observed_thread.SuspendCount, expected_thread.SuspendCount);
|
||||
EXPECT_EQ(observed_thread.PriorityClass, expected_thread.PriorityClass);
|
||||
EXPECT_EQ(observed_thread.Priority, expected_thread.Priority);
|
||||
EXPECT_EQ(observed_thread.Teb, expected_thread.Teb);
|
||||
|
||||
EXPECT_EQ(observed_thread.Stack.StartOfMemoryRange,
|
||||
expected_thread.Stack.StartOfMemoryRange);
|
||||
EXPECT_EQ(observed_thread.Stack.Memory.DataSize,
|
||||
expected_thread.Stack.Memory.DataSize);
|
||||
if (stack) {
|
||||
ASSERT_NE(observed->Stack.Memory.DataSize, 0u);
|
||||
ASSERT_NE(observed->Stack.Memory.Rva, 0u);
|
||||
ASSERT_NE(observed_thread.Stack.Memory.DataSize, 0u);
|
||||
ASSERT_NE(observed_thread.Stack.Memory.Rva, 0u);
|
||||
ASSERT_GE(file_contents.size(),
|
||||
observed->Stack.Memory.Rva + observed->Stack.Memory.DataSize);
|
||||
observed_thread.Stack.Memory.Rva +
|
||||
observed_thread.Stack.Memory.DataSize);
|
||||
*stack = &observed->Stack;
|
||||
} else {
|
||||
EXPECT_EQ(observed->Stack.StartOfMemoryRange, 0u);
|
||||
EXPECT_EQ(observed->Stack.Memory.DataSize, 0u);
|
||||
EXPECT_EQ(observed->Stack.Memory.Rva, 0u);
|
||||
EXPECT_EQ(observed_thread.Stack.StartOfMemoryRange, 0u);
|
||||
EXPECT_EQ(observed_thread.Stack.Memory.DataSize, 0u);
|
||||
EXPECT_EQ(observed_thread.Stack.Memory.Rva, 0u);
|
||||
}
|
||||
|
||||
EXPECT_EQ(observed->ThreadContext.DataSize, expected->ThreadContext.DataSize);
|
||||
ASSERT_NE(observed->ThreadContext.DataSize, 0u);
|
||||
ASSERT_NE(observed->ThreadContext.Rva, 0u);
|
||||
EXPECT_EQ(observed_thread.ThreadContext.DataSize,
|
||||
expected_thread.ThreadContext.DataSize);
|
||||
ASSERT_NE(observed_thread.ThreadContext.DataSize, 0u);
|
||||
ASSERT_NE(observed_thread.ThreadContext.Rva, 0u);
|
||||
ASSERT_GE(file_contents.size(),
|
||||
observed->ThreadContext.Rva + expected->ThreadContext.DataSize);
|
||||
*context_base = &file_contents[observed->ThreadContext.Rva];
|
||||
observed_thread.ThreadContext.Rva +
|
||||
expected_thread.ThreadContext.DataSize);
|
||||
*context_base = &file_contents[observed_thread.ThreadContext.Rva];
|
||||
}
|
||||
|
||||
TEST(MinidumpThreadWriter, OneThread_x86_NoStack) {
|
||||
|
@ -38,12 +38,20 @@ void TestMinidumpMemoryWriter::SetShouldFailRead(bool should_fail) {
|
||||
void ExpectMinidumpMemoryDescriptor(
|
||||
const MINIDUMP_MEMORY_DESCRIPTOR* expected,
|
||||
const MINIDUMP_MEMORY_DESCRIPTOR* observed) {
|
||||
EXPECT_EQ(observed->StartOfMemoryRange, expected->StartOfMemoryRange);
|
||||
EXPECT_EQ(observed->Memory.DataSize, expected->Memory.DataSize);
|
||||
if (expected->Memory.Rva != 0) {
|
||||
MINIDUMP_MEMORY_DESCRIPTOR expected_descriptor;
|
||||
MINIDUMP_MEMORY_DESCRIPTOR observed_descriptor;
|
||||
|
||||
memcpy(&expected_descriptor, expected, sizeof(expected_descriptor));
|
||||
memcpy(&observed_descriptor, observed, sizeof(observed_descriptor));
|
||||
|
||||
EXPECT_EQ(observed_descriptor.StartOfMemoryRange,
|
||||
expected_descriptor.StartOfMemoryRange);
|
||||
EXPECT_EQ(observed_descriptor.Memory.DataSize,
|
||||
expected_descriptor.Memory.DataSize);
|
||||
if (expected_descriptor.Memory.Rva != 0) {
|
||||
constexpr uint32_t kMemoryAlignment = 16;
|
||||
EXPECT_EQ(observed->Memory.Rva,
|
||||
(expected->Memory.Rva + kMemoryAlignment - 1) &
|
||||
EXPECT_EQ(observed_descriptor.Memory.Rva,
|
||||
(expected_descriptor.Memory.Rva + kMemoryAlignment - 1) &
|
||||
~(kMemoryAlignment - 1));
|
||||
}
|
||||
}
|
||||
|
@ -239,8 +239,6 @@ crashpad_static_library("snapshot") {
|
||||
|
||||
public_configs = [ "..:crashpad_config" ]
|
||||
|
||||
configs = [ "..:disable_ubsan" ]
|
||||
|
||||
public_deps = [ ":context" ]
|
||||
|
||||
deps = [
|
||||
|
1
third_party/googletest/BUILD.gn
vendored
1
third_party/googletest/BUILD.gn
vendored
@ -28,7 +28,6 @@ if (crashpad_is_in_chromium) {
|
||||
group("googletest") {
|
||||
testonly = true
|
||||
public_deps = [ "//third_party/googletest:gtest" ]
|
||||
public_configs = [ "../..:disable_ubsan" ]
|
||||
}
|
||||
group("googlemock") {
|
||||
testonly = true
|
||||
|
@ -565,8 +565,6 @@ crashpad_static_library("util") {
|
||||
|
||||
public_configs = [ "..:crashpad_config" ]
|
||||
|
||||
configs = [ "..:disable_ubsan" ]
|
||||
|
||||
# Include generated files starting with "util".
|
||||
if (crashpad_is_in_fuchsia) {
|
||||
include_dirs = [ "$root_gen_dir/third_party/crashpad" ]
|
||||
|
@ -66,11 +66,12 @@ class FileIOWriteAll final : public internal::WriteAllInternal {
|
||||
namespace internal {
|
||||
|
||||
bool ReadExactlyInternal::ReadExactly(void* buffer, size_t size, bool can_log) {
|
||||
char* buffer_c = static_cast<char*>(buffer);
|
||||
uintptr_t buffer_int = reinterpret_cast<uintptr_t>(buffer);
|
||||
size_t total_bytes = 0;
|
||||
size_t remaining = size;
|
||||
while (remaining > 0) {
|
||||
FileOperationResult bytes_read = Read(buffer_c, remaining, can_log);
|
||||
FileOperationResult bytes_read =
|
||||
Read(reinterpret_cast<char*>(buffer_int), remaining, can_log);
|
||||
if (bytes_read < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -81,7 +82,7 @@ bool ReadExactlyInternal::ReadExactly(void* buffer, size_t size, bool can_log) {
|
||||
break;
|
||||
}
|
||||
|
||||
buffer_c += bytes_read;
|
||||
buffer_int += bytes_read;
|
||||
remaining -= bytes_read;
|
||||
total_bytes += bytes_read;
|
||||
}
|
||||
@ -96,17 +97,18 @@ bool ReadExactlyInternal::ReadExactly(void* buffer, size_t size, bool can_log) {
|
||||
}
|
||||
|
||||
bool WriteAllInternal::WriteAll(const void* buffer, size_t size) {
|
||||
const char* buffer_c = static_cast<const char*>(buffer);
|
||||
uintptr_t buffer_int = reinterpret_cast<uintptr_t>(buffer);
|
||||
|
||||
while (size > 0) {
|
||||
FileOperationResult bytes_written = Write(buffer_c, size);
|
||||
FileOperationResult bytes_written =
|
||||
Write(reinterpret_cast<const char*>(buffer_int), size);
|
||||
if (bytes_written < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DCHECK_NE(bytes_written, 0);
|
||||
|
||||
buffer_c += bytes_written;
|
||||
buffer_int += bytes_written;
|
||||
size -= bytes_written;
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ bool WriteRequest(Stream* stream,
|
||||
}
|
||||
}
|
||||
|
||||
write_start = buf.crlf - size_len;
|
||||
write_start = static_cast<char*>(buf.crlf) - size_len;
|
||||
write_size = size_len + sizeof(buf.crlf) + data_bytes + kCRLFSize;
|
||||
} else {
|
||||
// When not using chunked encoding, only use buf.data.
|
||||
|
Loading…
x
Reference in New Issue
Block a user