From: Jeff King <peff@peff.net>
To: Elijah Newren <newren@gmail.com>
Cc: paul@mad-scientist.net, git@vger.kernel.org
Subject: Re: Anyone know why git ls-remote output might be corrupted?
Date: Sun, 4 Jun 2023 02:30:10 -0400 [thread overview]
Message-ID: <20230604063010.GA47137@coredump.intra.peff.net> (raw)
In-Reply-To: <20230604062556.GA42964@coredump.intra.peff.net>
On Sun, Jun 04, 2023 at 02:25:57AM -0400, Jeff King wrote:
> It does look like glibc's stdio will throw away buffer contents that get
> EAGAIN. Doing:
>
> perl -MFcntl -e '
> fcntl(STDOUT, F_GETFL, $flags);
> $flags |= O_NONBLOCK;
> fcntl(STDOUT, F_SETFL, $flags);
> exec @ARGV;
> ' git ls-remote . | (sleep 1; tee output) | sha256sum
>
> does result in some missing writes and broken input that looks like
> what's going on in this thread (in this case, it's writing to my
> terminal, which isn't fast enough to keep up; but you could also pipe to
> something like "tee output | sha256sum" to see that the output changes
> with each run). And naturally you'll need a big enough output from
> ls-remote to fill the pipe buffer.
Sorry for some slight confusion above. I edited my example command to
show piping to "sha256sum", but didn't modify the paragraph below it
(originally I was not piping anywhere, just sending to the terminal).
Adding the "sleep 1" means that the command will always fail (ls-remote
easily writes all of its output and hits EAGAIN before the other side
reads anything). But it means that the output is deterministic (the
first PIPE_BUF bytes make it through, and nothing else does). Removing
the sleep makes the output non-deterministic, but much more interesting
(you get missing chunks in the interior of the output).
So perhaps:
perl ... git ls-remote . | tee output | sha256sum
is the most interesting case, because you'll get one of several possible
broken outputs, which you can identify by the changing sha256 output
(and then see the actual breakage by peeking at the "output" file).
-Peff
next prev parent reply other threads:[~2023-06-04 6:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 18:59 Anyone know why git ls-remote output might be corrupted? Paul Smith
2023-06-02 19:12 ` Paul Smith
2023-06-02 19:34 ` rsbecker
2023-06-02 19:53 ` Paul Smith
2023-06-02 20:02 ` rsbecker
2023-06-02 20:12 ` Paul Smith
2023-06-03 1:17 ` Elijah Newren
2023-06-03 1:12 ` Elijah Newren
2023-06-04 6:00 ` Jeff King
2023-06-04 6:25 ` Jeff King
2023-06-04 6:30 ` Jeff King [this message]
2023-06-09 15:33 ` Paul Smith
2023-06-09 18:58 ` Junio C Hamano
2023-06-12 19:59 ` Paul Smith
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=20230604063010.GA47137@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=newren@gmail.com \
--cc=paul@mad-scientist.net \
/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;
as well as URLs for NNTP newsgroup(s).