Git development
 help / color / mirror / Atom feed
From: Jan Palus <jpalus@fastmail.com>
To: git@vger.kernel.org
Cc: Andrew Au <cshung@gmail.com>, Junio C Hamano <gitster@pobox.com>
Subject: regression 2.54.0: test suite hangs indefinitely with mksh
Date: Wed, 22 Apr 2026 21:00:30 +0200	[thread overview]
Message-ID: <aekVSi4iu9YLaPLQ@rock.grzadka> (raw)

If /bin/sh points to mksh, git's test suite hangs forever and never
completes. An example of process tree for such hung test:

$ pstree -a `pgrep -f ./t5702-protocol-v2.sh`  
t5702-protocol- ./t5702-protocol-v2.sh
  └─git -c protocol.version=0 ls-remote -o hello -o worldfile:///home/users/builder/rpm/BUILD/gi
      └─sh -c git-upload-pack '/home/users/builder/rpm/BUILD/git/t/trash directory.t5702-protocol-v2/file_parent'...
          └─git-upload-pack /home/users/builder/rpm/BUILD/git/t/trash directory.t5702-protocol-v2/file_parent

bisect points to the following commit:

commit dd3693eb0859274d62feac8047e1d486b3beaf31 (HEAD)
Author: Andrew Au <cshung@gmail.com>
Date:   Thu Mar 12 22:49:37 2026

    transport-helper, connect: use clean_on_exit to reap children on abnormal exit
    
    When a long-running service (e.g., a source indexer) runs as PID 1
    inside a container and repeatedly spawns git, git may in turn spawn
    child processes such as git-remote-https or ssh. If git exits abnormally
    (e.g., via exit(128) on a transport error), the normal cleanup paths
    (disconnect_helper, finish_connect) are bypassed, and these children are
    never waited on. The children are reparented to PID 1, which does not
    reap them, so they accumulate as zombies over time.
    
    Set clean_on_exit and wait_after_clean on child_process structs in both
    transport-helper.c and connect.c so that the existing run-command
    cleanup infrastructure handles reaping on any exit path. This avoids
    rolling custom atexit handlers that call finish_command(), which could
    deadlock if the child is blocked waiting for the parent to close a pipe.
    
    The clean_on_exit mechanism sends SIGTERM first, then waits, ensuring
    the child terminates promptly. It also handles signal-based exits, not
    just atexit.
    
    Signed-off-by: Andrew Au <cshung@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>

From commit message alone it seems the change tries to avoid reparenting
child processes to PID 1, however this does not seem to work for
processes which were spawned with "sh -c".

For example if /bin/sh points to bash tests pass because bash appears to
react to SIGTERM differently -- shell process ends but its children are
reparented anyway.

mksh on the other hand seems to ignore SIGTERM (or queues it?) but
waits for child process and so test suite never ends.

             reply	other threads:[~2026-04-22 19:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-22 19:00 Jan Palus [this message]
2026-04-22 22:35 ` regression 2.54.0: test suite hangs indefinitely with mksh Jeff King
2026-04-22 23:00   ` [PATCH] Revert "transport-helper, connect: use clean_on_exit to reap children on abnormal exit" Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aekVSi4iu9YLaPLQ@rock.grzadka \
    --to=jpalus@fastmail.com \
    --cc=cshung@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox