]> git.ipfire.org Git - thirdparty/git.git/commitdiff
run-command: don't spam trace2_child_exit()
authorJosh Steadmon <steadmon@google.com>
Tue, 7 Jun 2022 18:21:57 +0000 (11:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Jun 2022 19:48:19 +0000 (12:48 -0700)
In rare cases[1], wait_or_whine() cannot determine a child process's
status (and will return -1 in this case). This can cause Git to issue
trace2 child_exit events despite the fact that the child may still be
running. In pathological cases, we've seen > 80 million exit events in
our trace logs for a single child process.

Fix this by only issuing trace2 events in finish_command_in_signal() if
we get a value other than -1 from wait_or_whine(). This can lead to
missing child_exit events in such a case, but that is preferable to
duplicating events on a scale that threatens to fill the user's
filesystem with invalid trace logs.

[1]: This can happen when:

* waitpid() returns -1 and errno != EINTR
* waitpid() returns an invalid PID
* the status set by waitpid() has neither the WIFEXITED() nor
  WIFSIGNALED() flags

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
run-command.c

index a8501e38cebe50f6a1fefb6d31d92ce049b96ac3..e0fe2418a296326e227fbe032b803a041ed374f2 100644 (file)
@@ -983,7 +983,8 @@ int finish_command(struct child_process *cmd)
 int finish_command_in_signal(struct child_process *cmd)
 {
        int ret = wait_or_whine(cmd->pid, cmd->args.v[0], 1);
-       trace2_child_exit(cmd, ret);
+       if (ret != -1)
+               trace2_child_exit(cmd, ret);
        return ret;
 }