You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running locally I occasionally hit the maximum 3 tries in this test (though I haven't seen it fail). Putting it up to 5 might make this a bit more robust.
I tried experimenting with removing the exec.Command("something-that-does-not-exist-binary") and I still occasionally see fdGrowth hit 4. I'm wondering if the exec.Command("lsof", "-b", "-n", "-p", strconv.Itoa(os.Getpid())).Output() call is allocating pipes and lsof is sometimes seeing them. This might also explain another observation I made which is that fdGrowth is sometimes negative.
I played around with strace and I think what is happening is:
Parent process creates 4 pipes, with 2 FDs each: stdin, stdout, stderr & error status
Parent process starts child process (which inherits the FDs of the pipes)
Parent process closes its copies of the FDs it created for the child process
Child process starts, overwrites (dup2) its stdin, stdout and stderr with the pipe FDs
Child process executes the command (in this case lsof)
This looks like a race condition, there is nothing preventing step 3 being delayed until after step 5 has started. So lsof can see the fds the parent process created for its process.
Some possible solutions:
a. Accept a difference of up to 4 (maybe 5) fds. Probably accompanied with an increase in the number of failed exec calls (the cleanup of which this test is trying to check) from 4 to 6 or more so that a leak of 1 pipe is definitely detected.
b. Add some sort of synchronisation between the parent and child processes.
I suspect that either of these fixes will remove the need for retries.
https://build.golang.org/log/085751bd5790fd794a1a711f0f15bdefa146443a
/cc @mundaym @ianlancetaylor
The text was updated successfully, but these errors were encountered: