| Summary: | memcheck/tests/pointer-trace fails when run on NFS filesystem | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | Mark Wielaard <mark> |
| Component: | general | Assignee: | Julian Seward <jseward> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | ahajkova |
| Priority: | NOR | ||
| Version First Reported In: | 3.24 GIT | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
commit 86ac4f2b004f57fa11224efafc1cd1c8fa8ded84 Author: Mark Wielaard <mark@klomp.org> Date: Sun Mar 9 15:59:29 2025 +0100 coregrind/m_debuginfo: don't try to examine zero sized mmapped files When run on an nfs filesystem memcheck/tests/pointer-trace fails because it generates warnings "connection to image failed". This is caused by trying to mmap a deleted file which the nfs file system represents as a (hidden) regular file. This is normally not a problem except when that file is empty. Fix this by not trying to check whether a file is an ELF or MACHO against an empty (regular) file in di_notify_mmap. An empty file is never a valid ELF or MACHO file (and cannot be represented as DiImage). https://bugs.kde.org/show_bug.cgi?id=501119 |
When run on an nfs filesystem memcheck/tests/pointer-trace fails because it generates warnings "connection to image failed". This is caused by trying to mmap a deleted file which the nfs file system represents as a (hidden) regular file. This is normally not a problem except when that file is empty. Fix this by not trying to check whether a file is an ELF or MACHO against an empty (regular) file in di_notify_mmap. And empty file is never a valid ELF or MACHO file (and cannot be represented as DiImage). diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 97d0f35c0..2e97fca4d 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -1216,8 +1216,14 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) } /* Finally, the point of all this stattery: if it's not a regular file, - don't try to read debug info from it. */ - if (! VKI_S_ISREG(statbuf.mode)) + don't try to read debug info from it. Also if it is a "regular file" + but has a zero size then skip it. Having a zero size will definitely + fail when trying to create an DiImage and wouldn't be a valid elf or + macho file. This can happen when mmapping a deleted file, which + would normally fail in the check above, because the stat call will + fail. But if the deleted file is on an NFS file system then a fake + (regular) empty file might be returned. */ + if (! VKI_S_ISREG(statbuf.mode) || statbuf.size == 0) return 0; /* no uses of statbuf below here. */