From: Arnaud Giersch Date: Wed, 10 Apr 2019 19:06:35 +0000 (+0200) Subject: Exclude overlapping portions of regions. X-Git-Tag: v3.22.2~151 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c2dbec8adf84cdd50fddeeb88f594d5ae9e9cdec Exclude overlapping portions of regions. Sometimes, offending regions don't match perfectly. Don't ask me why... Should solve problems seen on Jenkins with UBSan or Coverage builds, and tests *-mpich3-coll-*-mmap-*. --- diff --git a/src/smpi/internals/smpi_memory.cpp b/src/smpi/internals/smpi_memory.cpp index 49e4ab19b6..04a59d607c 100644 --- a/src/smpi/internals/smpi_memory.cpp +++ b/src/smpi/internals/smpi_memory.cpp @@ -75,11 +75,12 @@ static void smpi_get_executable_global_size() ++i; if (i != map.end() && i->pathname.empty() && (i->prot & PROT_RWX) == PROT_RW && (char*)i->start_addr == smpi_data_exe_start + smpi_data_exe_size) { - // Only count this region if it was not already present in the initial map. - auto found = std::find_if(begin(initial_vm_map), end(initial_vm_map), - [&i](const simgrid::xbt::VmMap& m) { return m.start_addr == i->start_addr; }); - if (found == end(initial_vm_map)) - smpi_data_exe_size = (char*)i->end_addr - smpi_data_exe_start; + // Only count the portion of this region not present in the initial map. + auto found = std::find_if(initial_vm_map.begin(), initial_vm_map.end(), [&i](const simgrid::xbt::VmMap& m) { + return i->start_addr <= m.start_addr && m.start_addr < i->end_addr; + }); + auto end_addr = (found == initial_vm_map.end() ? i->end_addr : found->start_addr); + smpi_data_exe_size = (char*)end_addr - smpi_data_exe_start; } return; }