Bug 514762

Summary: Many "Bad file descriptor" messages when using --track-fds=yes and -d on systems without /proc
Product: [Developer tools] valgrind Reporter: Paul Floyd <pjfloyd>
Component: generalAssignee: Paul Floyd <pjfloyd>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 3.27 GIT   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Paul Floyd 2026-01-17 20:21:06 UTC
Loads of
--47513:1:VG_(fcnt fcntl error 9 Bad file descriptor
messages

This is due to

init_preopened_fds_without_proc_self_fd()

   for (i = 0; i < count; i++)
      if (VG_(fcntl)(i, VKI_F_GETFL, 0) != -1)
         ML_(record_fd_open_named)(-1, i);

The loop will result in one message per file that does not exist. On my RPi FreeBSD rlimit open files is 231219 and indeed I do see 231214 messages.

I'll turn off logging for that loop.
Comment 1 Paul Floyd 2026-01-17 20:33:01 UTC
On second thoughts, I'll just remove the VG_(debugLog) call. Pretty much all of the other libcfile.c functions do not log errors.
Comment 2 Paul Floyd 2026-01-18 08:23:35 UTC
commit ed41469979c674ef8229cd7cf818fc3c27ead23c (HEAD -> master, origin/master, origin/HEAD)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Sat Jan 17 21:43:36 2026 +0100

    Bug 514762 - Many "Bad file descriptor" messages when using --track-fds=yes and -d on systems without /proc
    
    Just a one-line deletion in the end.