From c1047e1e198944982ce7ca28362a0a34ffbf0bfd Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Fri, 16 Nov 2018 22:43:32 +0000 Subject: [PATCH] Bug 1497669 - Relax breakpad's constraints when merging module mappings on Linux r=ted This makes a few small but significant changes to the logic breakpad uses to merge module memory mappings: - First of all we merge areas of reserved space if their offset is either 0 or the end of the previous non-reserved mapping. - Whenever we encounter an executable mapping we flag all the merged modules as executable. This shouldn't happen but apparently some older Android linkers suffered from a bug that caused the first mapping not to be executable. - Last but not least we record the raw end address of a module on Android. This shouldn't affect us but it's done in upstream breakpad so it probably doesn't hurt. Differential Revision: https://phabricator.services.mozilla.com/D12113 --- .../linux/minidump_writer/linux_dumper.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/toolkit/crashreporter/breakpad-client/linux/minidump_writer/linux_dumper.cc b/toolkit/crashreporter/breakpad-client/linux/minidump_writer/linux_dumper.cc index 93f104eae714..a861c057017e 100644 --- a/toolkit/crashreporter/breakpad-client/linux/minidump_writer/linux_dumper.cc +++ b/toolkit/crashreporter/breakpad-client/linux/minidump_writer/linux_dumper.cc @@ -617,14 +617,16 @@ bool LinuxDumper::EnumerateMappings() { name = kLinuxGateLibraryName; offset = 0; } - // Merge adjacent mappings with the same name into one module, - // assuming they're a single library mapped by the dynamic linker + // Merge adjacent mappings into one module, assuming they're a single + // library mapped by the dynamic linker. if (name && !mappings_.empty()) { MappingInfo* module = mappings_.back(); if ((start_addr == module->start_addr + module->size) && (my_strlen(name) == my_strlen(module->name)) && (my_strncmp(name, module->name, my_strlen(name)) == 0)) { + module->system_mapping_info.end_addr = end_addr; module->size = end_addr - module->start_addr; + module->exec |= exec; line_reader->PopLine(line_len); continue; } @@ -635,12 +637,13 @@ bool LinuxDumper::EnumerateMappings() { // and which directly follow an executable mapping. if (!name && !mappings_.empty()) { MappingInfo* module = mappings_.back(); - if ((start_addr == module->start_addr + module->size) && + uintptr_t module_end_addr = module->start_addr + module->size; + if ((start_addr == module_end_addr) && module->exec && module->name[0] == '/' && - offset == 0 && my_strncmp(i2, - kReservedFlags, - sizeof(kReservedFlags) - 1) == 0) { + ((offset == 0) || (offset == module_end_addr)) && + my_strncmp(i2, kReservedFlags, + sizeof(kReservedFlags) - 1) == 0) { module->size = end_addr - module->start_addr; line_reader->PopLine(line_len); continue;