Mac: more robust __crash_info on 13+

It looks like macOS 13 only *sometimes* puts __crash_info in
__DATA_DIRTY. Instead of splitting by version check, let's just look
in __DATA_DIRTY if we can't find it in __DATA.

Bug: chromium:1372165
Change-Id: I99d2e759c66841d982039449e83f8658259d7ed1
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4197706
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
This commit is contained in:
Leonard Grey 2023-01-27 14:48:54 -05:00 committed by Crashpad LUCI CQ
parent ad2e043288
commit 85b7d3dd6f

View File

@ -26,7 +26,6 @@
#include "snapshot/mac/mach_o_image_reader.h" #include "snapshot/mac/mach_o_image_reader.h"
#include "snapshot/mac/process_reader_mac.h" #include "snapshot/mac/process_reader_mac.h"
#include "snapshot/snapshot_constants.h" #include "snapshot/snapshot_constants.h"
#include "util/mac/mac_util.h"
#include "util/stdlib/strnlen.h" #include "util/stdlib/strnlen.h"
namespace crashpad { namespace crashpad {
@ -69,11 +68,16 @@ std::vector<AnnotationSnapshot> MachOImageAnnotationsReader::AnnotationsList()
void MachOImageAnnotationsReader::ReadCrashReporterClientAnnotations( void MachOImageAnnotationsReader::ReadCrashReporterClientAnnotations(
std::vector<std::string>* vector_annotations) const { std::vector<std::string>* vector_annotations) const {
mach_vm_address_t crash_info_address; mach_vm_address_t crash_info_address;
const char* segment =
MacOSVersionNumber() >= 13'00'00 ? "__DATA_DIRTY" : SEG_DATA;
const process_types::section* crash_info_section = const process_types::section* crash_info_section =
image_reader_->GetSectionByName( image_reader_->GetSectionByName(
segment, "__crash_info", &crash_info_address); SEG_DATA, "__crash_info", &crash_info_address);
if (!crash_info_section) {
// On macOS 13, under some circumstances, `__crash_info` ends up in the
// `__DATA_DIRTY` segment. This is known to happen for `dyld`.
crash_info_section = image_reader_->GetSectionByName(
"__DATA_DIRTY", "__crash_info", &crash_info_address);
}
if (!crash_info_section) { if (!crash_info_section) {
return; return;
} }