]> git.ipfire.org Git - thirdparty/valgrind.git/commit
Remove fdleak.h CLOSE_INHERITED_FDS workaround
authorMark Wielaard <mark@klomp.org>
Wed, 3 Sep 2025 16:29:43 +0000 (18:29 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 3 Sep 2025 17:04:39 +0000 (19:04 +0200)
commitb6ab5a762d094cfb61696cdbad5413ef0366c496
treeb900bb4d72471bc94745b3a2ab0899364d5ba116
parenta7fe47937b088aff567f9de7c0a4275a6ca6e139
Remove fdleak.h CLOSE_INHERITED_FDS workaround

This workaround was necessary with very old perl implementations (from
2008) which might execute programs with some non-standard file
descriptors not closed. The macro would close all file descriptors 3
or higher so --track-fds wouldn't report on them.

More recently --track-fds also reports on bad file descriptor
usage. First only double or bad close calls were reported. This would
cause lots of warnings for the close_inherited file descriptor loop
because almost all of those file descriptors were never opened, so
--track-fds would report those. To work around that an fstat call was
added before the close to make sure the file descriptor existed.

This fstat workaround in close_inherited only worked because fstat
didn't have a fd_allowed check. Which is a bug that should be
fixed. On some systems fstat actually calls the fstatat syscall and
that did recently got the fd_allowed check, so on systems that use
fstatat for fstat various fdleak tests started failing.

We could test for and use close_range, which is smart enough to not
warn about never opened file descriptors in the range. But it seems
simpler to just get rid of the CLOSE_INHERITED_FDS macro because the
problematic perl implementation is now so old that nobody uses it
anymore.
14 files changed:
none/tests/fdleak.h
none/tests/fdleak_cmsg.c
none/tests/fdleak_creat.c
none/tests/fdleak_dup.c
none/tests/fdleak_dup2.c
none/tests/fdleak_fcntl.c
none/tests/fdleak_ipv4.c
none/tests/fdleak_open.c
none/tests/fdleak_pipe.c
none/tests/fdleak_socketpair.c
none/tests/file_dclose.c
none/tests/rlimit64_nofile.c
none/tests/rlimit_nofile.c
none/tests/socket_close.c