Version: 3.2.3 (using KDE Devel) Installed from: Compiled sources Compiler: gcc 3.4.6 OS: Linux I'm using the --track-fds option to detect file descriptor leakage in my application. I've noticed that it includes file descriptors 0, 1, and 2 (stdin, stdout, and stderr) in its report. Ideally these should not be reported as errors since virtually all programs do not close these on exit. Having these open when the program exits is not really a bug; the main thing most people would want to know from --track-fds is if they have inadvertently left other files or sockets open. Additionally, the -q option is supposed to cause valgrind to only print output on error conditions. Even with a program that does close stdin/out/err before exiting, the message "FILE DESCRIPTORS: 0 open at exit" is still reported. Ideally this message should only be printed if -q is not specified, and only file descriptors greater than 2 should be listed (and included in the count). I have written a patch which modifies the function VG_(show_open_fds) to give this behaviour which I will try to attach to this bug report.
Created attachment 19491 [details] patch against valgrind 3.2.3 to modify --track-fds output
Seems reasonable. Will commit unless anyone complains.
Has the patch been applied yet?
I think it really should check to see if those fds are a terminal as in some situations they may have been closed and replaced with others
also should verify that its the controlling terminal if possible but not sure how or if this is possible
Created attachment 125774 [details] patch against valgrind 3.16-git to modify --track-fds output This updated patch is against the current code in git
Created attachment 135494 [details] Patch including --track-fds=all, testsuite updates and documentation For some reason this keeps being dropped while it is a good idea and people approve of the fix. I updated the patch a little to include a new variant --track-fds=all which does include tracking/reporting on stdin/out/err. It also updates the testsuite and documentation.
commit c9781cc97e719c1ecf0cfad9ca2f86631c017268 Author: Mark Wielaard <mark@klomp.org> Date: Mon Feb 8 00:25:52 2021 +0100 PR140939 --track-fds reports leakage of stdout/in/err and doesn't respect -q Make --track-fds=yes not report on file descriptors 0, 1, and 2 (stdin, stdout, and stderr) by default. Add a new option --track-fds=all that does report on the std file descriptors still being open. Update testsuite and documentation. Original patch by Peter Kelly <pmk@cs.adelaide.edu.au> Updated by Daniel Fahlgren <daniel@fahlgren.se> https://bugs.kde.org/show_bug.cgi?id=140939