On Mon, Jan 06, 2025 at 12:16:51PM +0100, Patrick Steinhardt wrote: > Fix the issue by making the writer fill the pipe buffer before we > execute git-submodule(1). Ideally, it would be git-submodule(1) itself > that does produce all that data, but it would require us to create a > large amount of submodules, which is inefficient. Instead, we use Perl > to print gibberish until the buffer is filled. > > To verify that this works as expected one can apply the following patch > to the preimage of this commit, which used to reliably trigger the race: > > diff --git a/t/t7422-submodule-output.sh b/t/t7422-submodule-output.sh > index f21e920367..9338c75626 100755 > --- a/t/t7422-submodule-output.sh > +++ b/t/t7422-submodule-output.sh > @@ -168,7 +168,7 @@ done > > test_expect_success !MINGW 'git submodule status --recursive propagates SIGPIPE' ' > { git submodule status --recursive 2>err; echo $?>status; } | > - grep -q X/S && > + { sleep 1 && grep -q X/S; } && > test_must_be_empty err && > test_match_signal 13 "$(cat status)" > ' > > With the pipe-stuffing workaround the test runs successfully. Sadly this isn't enough. The pipe-stuffing solves the race with grep _starting_ (and thus the extra "sleep"), but the fundamental race we've seen in practice still remains. See my reply the v1 thread for details. -Peff