https://bugs.kde.org/show_bug.cgi?id=504177

            Bug ID: 504177
           Summary: FILE DESCRIPTORS banner shows when closing some
                    inherited file descriptors
    Classification: Developer tools
           Product: valgrind
           Version: 3.25.0
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: jsew...@acm.org
          Reporter: m...@klomp.org
  Target Milestone: ---

With valgrind 3.25.0 the following shows the FILE DESCRIPTORS banner, when it
shouldn't

$ valgrind -q --track-fds=yes cat /dev/null
==1937149== FILE DESCRIPTORS: 1 open (3 inherited) at exit.
==1937149== 

cat (coreutils) closes stdout and stderr before exit. The still open file
descriptor is stdin.
Note that it still says 3 inherited.

The problem is that the check whether or not to show the banner is:
(fd_count - inherited == 0)

The fix seems to be to check whether the inherited file descriptors are already
closed:

diff --git a/coregrind/m_syswrap/syswrap-generic.c
b/coregrind/m_syswrap/syswrap-generic.c
index 82a682a5ce55..81c8fc028d88 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -987,7 +987,7 @@ void VG_(show_open_fds) (const HChar* when)
    int inherited = 0;

    for (i = allocated_fds; i; i = i->next) {
-      if (i->where == NULL)
+      if (i->where == NULL && !i->fd_closed)
          inherited++;
    }

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to