Bug 1237206
| Summary: | valgrind wrongly discards memory regions | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Miloš Prchlík <mprchlik> |
| Component: | valgrind | Assignee: | Mark Wielaard <mjw> |
| Status: | CLOSED ERRATA | QA Contact: | Miloš Prchlík <mprchlik> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 7.2 | CC: | jakub, mfranc |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | ppc64le | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | valgrind-3.10.0-11.el7 | Doc Type: | Bug Fix |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2015-11-19 09:05:03 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | 1240796 | ||
| Bug Blocks: | |||
|
Description
Miloš Prchlík
2015-06-30 14:14:48 UTC
The fix is as follows:
[Index: coregrind/m_debuginfo/debuginfo.c
===================================================================
--- coregrind/m_debuginfo/debuginfo.c (revision 15387)@@ -68,7 +68,7 @@
+++ coregrind/m_debuginfo/debuginfo.c (working copy)
@@ -1038,7 +1038,7 @@
/* Note the details about the mapping. */
DebugInfoMapping map;
- map.avma = a;
+ map.avma = seg->start;
map.size = seg->end + 1 - seg->start;
map.foff = seg->offset;
map.rx = is_rx_map;
VG_(di_notify_mmap) assumes that the start of the segment (seg->start) returned by VG(am_find_nsegment) equals the address (a) returned by mmap. This usually is the case, but not here because of the following sequence of mmap calls to load glibc:
pid 21968] open("/lib64/power8/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
[pid 21968] mmap(0x4330000, 1922488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = 0x4330000
di_notify_mmap-0:
di_notify_mmap-1: 0x4330000-0x450ffff r-x
di_notify_mmap-2: /usr/lib64/power8/libc-2.17.so
di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
di_notify_mmap-4: noting details in DebugInfo* at 0x802899310
[pid 21968] mmap(0x44f0000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b0000) = 0x44f0000
di_notify_mmap-0:
di_notify_mmap-1: 0x44f0000-0x44fffff rw-
di_notify_mmap-2: /usr/lib64/power8/libc-2.17.so
di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
di_notify_mmap-4: noting details in DebugInfo* at 0x802899310
di_notify_mmap-5: achieved accept state for /usr/lib64/power8/libc-2.17.so
--21968-- Reading syms from /usr/lib64/power8/libc-2.17.so
[pid 21968] open("/usr/lib64/power8/libc-2.17.so", O_RDONLY) = 4
--21968-- ELF section outside all mapped regions
[pid 21968] mmap(0x4500000, 160, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4500000
di_notify_mmap-0:
di_notify_mmap-1: 0x4500000-0x450ffff rw-
[pid 21968] mmap(0x4500000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x4500000
di_notify_mmap-0:
di_notify_mmap-1: 0x44f0000-0x450ffff rw-
di_notify_mmap-2: /usr/lib64/power8/libc-2.17.so
di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
di_notify_mmap-4: noting details in DebugInfo* at 0x802899310
di_notify_mmap-5: achieved accept state for /usr/lib64/power8/libc-2.17.so
--21968-- Reading syms from /usr/lib64/power8/libc-2.17.so
Note how the last mmap was for address 0x4500000 but the aspace manager seems to have figured out this really is a continues file mapping for the segment 0x44f0000-0x450ffff.
Since the original code did use the mmap address (map.start) plus the length of the segment (map.size), the debuginfo mapping now covers some address space after the actual ELF file mapping. Once some other ELF file is mapped into this space the glibc mapping will be discarded because valgrind thinks it is replaced. This will also get rid of all the overrides causing the issue seen.
Patch is now upstream as valgrind svn r15398. Just for the record. This issue in binutils seems to have been the root cause: https://bugzilla.redhat.com/show_bug.cgi?id=1247126 Verified for build valgrind-3.10.0-16.el7, using pcp-3.10.6-2.el7. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2015-2259.html |