]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 514206 - Assertion '!sr_isError(sr)' failed - mmap fd points to an open descripto...
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 20 Jan 2026 06:44:31 +0000 (07:44 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 20 Jan 2026 06:44:31 +0000 (07:44 +0100)
Also reindent set_CEnt() a bit

NEWS
coregrind/m_debuginfo/debuginfo.c
coregrind/m_debuginfo/image.c

diff --git a/NEWS b/NEWS
index 1c93e13456f55187bc21342173ef93702d7d3699..5f7eb03bf3714414ef9ccfe65cc1f586d2429fd6 100644 (file)
--- 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
index f503fc8ee3eada7d354a064e1c7fcbf2bb37af93..8c63cfc390b9a2db1e9ab6f02eaca6fed13b119a 100644 (file)
@@ -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)
index 7b5847820cdfa5d1d5e8d1bbbe807def818d23c1..bbcffd5111454f51fea77c917e833ab7f503640a 100644 (file)
@@ -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