From: Paul Floyd Date: Tue, 20 Jan 2026 06:44:31 +0000 (+0100) Subject: Bug 514206 - Assertion '!sr_isError(sr)' failed - mmap fd points to an open descripto... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38609f9b87eb6908a4a04ed5882db337edaec765;p=thirdparty%2Fvalgrind.git Bug 514206 - Assertion '!sr_isError(sr)' failed - mmap fd points to an open descriptor to a PCI device Also reindent set_CEnt() a bit --- diff --git a/NEWS b/NEWS index 1c93e1345..5f7eb03bf 100644 --- a/NEWS +++ b/NEWS @@ -69,6 +69,8 @@ are not entered into bugzilla tend to get forgotten about or ignored. compiler warning 513475 Add SSE4.1 PMULLD instruction for x86 32 bit 514094 readlink("/proc/self/exe") overwrites buffer beyond its return value +514206 Assertion '!sr_isError(sr)' failed - mmap fd points to an open + descriptor to a PCI device 514613 Unclosed leak_summary/still_reachable tag in xml output 514659 ltp 20250930 vs linux 6.18.3 doesn't build 514762 Many "Bad file descriptor" messages when using --track-fds=yes and diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index f503fc8ee..8c63cfc39 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -1206,8 +1206,11 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) * --20208-- WARNING: Serious error when reading debug info * --20208-- When reading debug info from /proc/xen/privcmd: * --20208-- can't read file to inspect ELF header + * + * Also PCI devices, see bug 514206 */ - if (VG_(strncmp)(filename, "/proc/xen/", 10) == 0) + if (VG_(strncmp)(filename, "/proc/xen/", 10) == 0 || + VG_(strncmp)(filename, "/sys/devices/pci", 16) == 0) return 0; if (debug) diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c index 7b5847820..bbcffd511 100644 --- a/coregrind/m_debuginfo/image.c +++ b/coregrind/m_debuginfo/image.c @@ -588,30 +588,30 @@ static void set_CEnt ( const DiImage* img, UInt entNo, DiOffT off ) if (img->source.is_local) { // Simple: just read it if (img->source.fd == -1) { - VG_(memcpy)(&ce->data[0], ((const char *)img->source.session_id) + off, len); + VG_(memcpy)(&ce->data[0], ((const char *)img->source.session_id) + off, len); } else { - // PJF not quite so simple - see - // https://bugs.kde.org/show_bug.cgi?id=480405 - // if img->source.fd was opened with O_DIRECT the memory needs - // to be aligned and also the length - // that's a lot of hassle just to take a quick peek to see if - // is an ELF binary so just twiddle the flag before and after - // peeking. - // This doesn't seem to be a problem on FreeBSD. I haven't tested - // on macOS or Solaris, hence the conditional compilation + // PJF not quite so simple - see + // https://bugs.kde.org/show_bug.cgi?id=480405 + // if img->source.fd was opened with O_DIRECT the memory needs + // to be aligned and also the length + // that's a lot of hassle just to take a quick peek to see if + // is an ELF binary so just twiddle the flag before and after + // peeking. + // This doesn't seem to be a problem on FreeBSD. I haven't tested + // on macOS or Solaris, hence the conditional compilation #if defined(VKI_O_DIRECT) - Int flags = VG_(fcntl)(img->source.fd, VKI_F_GETFL, 0); - if (flags & VKI_O_DIRECT) { - VG_(fcntl)(img->source.fd, VKI_F_SETFL, flags & ~VKI_O_DIRECT); - } + Int flags = VG_(fcntl)(img->source.fd, VKI_F_GETFL, 0); + if (flags & VKI_O_DIRECT) { + VG_(fcntl)(img->source.fd, VKI_F_SETFL, flags & ~VKI_O_DIRECT); + } #endif - SysRes sr = VG_(pread)(img->source.fd, &ce->data[0], (Int)len, off); + SysRes sr = VG_(pread)(img->source.fd, &ce->data[0], (Int)len, off); #if defined(VKI_O_DIRECT) - if (flags & VKI_O_DIRECT) { - VG_(fcntl)(img->source.fd, VKI_F_SETFL, flags); - } + if (flags & VKI_O_DIRECT) { + VG_(fcntl)(img->source.fd, VKI_F_SETFL, flags); + } #endif - vg_assert(!sr_isError(sr)); + vg_assert(!sr_isError(sr)); } } else { // Not so simple: poke the server