Bug 202770 - open fd at exit --log-socket=127.0.0.1:1500 with --track-fds=yes and --trace-children=yes with a program that calls fork then exec
Summary: open fd at exit --log-socket=127.0.0.1:1500 with --track-fds=yes and --trace-...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.4.1
Platform: Gentoo Packages Linux
: NOR minor
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-06 10:39 UTC by David van Laatum
Modified: 2024-06-17 16:00 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David van Laatum 2009-08-06 10:39:52 UTC
(4) ==3737== Open AF_INET socket 3: 127.0.0.1:45266 <-> 127.0.0.1:1500
(4) ==3737==    <inherited from parent>

it appears that valgrind doesn't set CLOEXEC on the log socket.

also a way to suppress open fds would be nice as I end up with connections to my ldap server in the list as well (from nss_ldap or similar I assume).
Comment 1 Tom Hughes 2009-08-06 11:34:36 UTC
If you're using --trace-children=yes you don't want it to close-on-exec as you want it to continue logging as you trace the execed process.

I suspect this is really a variant of bug 140939 except that you have a logging descriptor that isn't stderr which means the patch on that bug probably needs enhancing to ignore the logging descriptor as well.
Comment 2 David van Laatum 2009-08-06 11:53:12 UTC
depends on if a new socket is opened after exec I suspect it is as the connection count goes up.
Comment 3 David van Laatum 2009-08-06 12:04:59 UTC
also should verify that its the controlling terminal if possible but not sure how or if this is possible
Comment 4 David van Laatum 2009-08-06 12:19:13 UTC
(In reply to comment #3)
> also should verify that its the controlling terminal if possible but not sure
> how or if this is possible

ops wrong bug
Comment 5 Mark Wielaard 2024-06-13 18:22:09 UTC
This seems a different variant of https://bugs.kde.org/show_bug.cgi?id=311655 but with --log-socket= instead of --log-file=
See also bug 488379
Comment 6 Mark Wielaard 2024-06-17 16:00:42 UTC
commit fbd7596f8342f0b0fbbe088d960da839a8bdb839
Author: Mark Wielaard <mark@klomp.org>
Date:   Sun Jun 16 21:23:08 2024 +0200

    Don't leave fds created with --log-file, --xml-file or --log-socket open
    
    prepare_sink_fd and prepare_sink_socket will create a new file
    descriptor for the output sink. finalize_sink_fd then copies the fd
    to the safe range, so it doesn't conflict with any application fds.
    
    If we created the original fd ourselves, it was a VgLogTo_File or
    VgLogTo_Socket, not VgLogTo_Fd, finalize_sink_fd should close it.
    
    Also close socket when connecting fails in VG_(connect_via_socket).
    
    Add a testcase for --log-file and --xml-file which prints output to
    /dev/stderr
    
    https://bugs.kde.org/show_bug.cgi?id=202770
    https://bugs.kde.org/show_bug.cgi?id=311655
    https://bugs.kde.org/show_bug.cgi?id=488379
    
    Co-authored-by: Alexandra Hájková <ahajkova@redhat.com