git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t5500.43: make the check a bit more robust

From
Jeff King <peff@peff.net>
Date
Oct 13, 2020, 18:55 UTC
Message-ID
<20201013185515.GA2994107@coredump.intra.peff.net>
In-Reply-To
<pull.753.git.1602600323973.gitgitgadget@gmail.com>
On Tue, Oct 13, 2020 at 02:45:23PM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 7 quoted lines
> Note: we have code in `demultiplex_sideband()` _specifically_ to stitch
> back together lines that were delivered in separate sideband packets.
> However, this stitching fails when a primary packet is delivered in
> between the two sideband packets: since a primary packet was received,
> `demultiplex_sideband()` has to return that (and cannot wait for other
> sideband packets, and therefore has to flush any incomplete line it
> received).

This sounds like a bug. We should accumulate multiple sideband 2 packets, even across data packets. And I think we _used_ to do that. The original recv_sideband() looked roughly like this:

	while (!retval) {
		 packet_read();
		 band = buf[0] & 0xff;
		 switch (band) {
		 case 3:
		   ...stuff data into outbuf...
		   retval = SIDEBAND_ERROR_REMOTE;
		   break;
		 case 2:
		   ...print full lines, stuff remainder into outbuf...
		   break; /* note, does _not_ set retval */
		 case 1:
		   write_or_die(out, buf + 1, len);
		   break; /* likewise, does not set retval */
		 default:
		   ...complain about broken sideband...
		   retval = SIDEBAND_PROTOCOL_ERROR;
		}
	}
	if (outbuf.len)
		...print outbuf...

So we would keep looping until we see EOF, sideband 3, or a protocol error. But notably we would not break out of the loop on bands 1 or 2, and we do not flush band 2 until we break out of the loop.

But then in fbd76cd450 (sideband: reverse its dependency on pkt-line, 2019-01-16), the function became demultiplex_sideband(). The loop went away, and we pump only a single packet on each call. When we see sideband 2, we do an early return. But on sideband 1, we continue to the cleanup: label, which flushes the scratch buffer.

I think we need to return from there without hitting that cleanup label, like this:

diff --git a/sideband.c b/sideband.c
index 0a60662fa6..a5405b9aaa 100644
--- a/sideband.c
+++ b/sideband.c
@@ -190,7 +190,7 @@ int demultiplex_sideband(const char *me, char *buf, int len,
 		return 0;
 	case 1:
 		*sideband_type = SIDEBAND_PRIMARY;
-		break;
+		return 1;
 	default:
 		strbuf_addf(scratch, "%s%s: protocol error: bad band #%d",
 			    scratch->len ? "\n" : "", me, band);

Does that make the problem go away for you?

>     Work around flakiness in t5500.43
>     
>     It seems that this test became flaky only recently, although I have to
>     admit that I have no idea why: the involved code does not seem to have
>     changed recently at all. It should have been fixed by 
>     https://lore.kernel.org/git/20200506220741.71021-1-jonathantanmy@google.com/
>     , but apparently wasn't completely fixed, despite what I said in that
>     thread.

I think this is a real bug, and we shouldn't be changing the tests to
accommodate. Users may actually see the broken lines, and our tests are
telling us that.

I suspect it's uncommon in practice because it requires the server side
also splitting the line across two packets. And while the server-side
upload-pack might get a partial write from a child pack-objects or
whatever, that should only happen if:

  - the pipe buffer fills up. Which is hard to do since our messages
    tend to be very small. So perhaps it implies a very tiny pipe
    buffer, and/or slow scheduling of the receiving side to actually
    clean it out.

  - the writer is fully buffering its stderr writes instead of sending
    them a line at a time

The latter seems a more likely candidate for switching from gcc to
Visual C (which presumably has a different libc / CRT).  I think the
client should be handling this more robustly, but it may be worth
digging into the buffering issue if it means progress may not be
delivered in quite as timely a way as we expect it to be.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 33 in “t5500.43: make the check a bit more robust”
  1. t5500.43: make the check a bit more robustJohannes Schindelin via GitGitGadget, Oct 13, 2020
  2. Junio C HamanoOct 13, 2020
  3. Jeff KingOct 13, 2020
  4. Junio C HamanoOct 13, 2020
  5. Jeff KingOct 13, 2020
  6. Johannes SchindelinOct 17, 2020
  7. Johannes SchindelinOct 17, 2020
  8. 0/3 Work around flakiness in t5500.43Johannes Schindelin via GitGitGadget, Oct 19, 2020
  9. 1/3 sideband: avoid reporting incomplete sideband messagesJohannes Schindelin via GitGitGadget, Oct 19, 2020
  10. Junio C HamanoOct 20, 2020
  11. Johannes SchindelinOct 20, 2020
  12. Junio C HamanoOct 20, 2020
  13. 2/3 sideband: report unhandled incomplete sideband messages as bugsJohannes Schindelin via GitGitGadget, Oct 19, 2020
  14. 3/3 sideband: add defense against packets missing a band designatorJohannes Schindelin via GitGitGadget, Oct 19, 2020
  15. Junio C HamanoOct 20, 2020
  16. Jeff KingOct 23, 2020
  17. Junio C HamanoOct 23, 2020
  18. Jeff KingOct 23, 2020
  19. Johannes SchindelinOct 23, 2020
  20. Jeff KingOct 23, 2020
  21. Johannes SchindelinOct 26, 2020
  22. 0/2 Work around flakiness in t5500.43Johannes Schindelin via GitGitGadget, Oct 26, 2020
  23. 1/2 sideband: avoid reporting incomplete sideband messagesJohannes Schindelin via GitGitGadget, Oct 26, 2020
  24. 2/2 sideband: report unhandled incomplete sideband messages as bugsJohannes Schindelin via GitGitGadget, Oct 26, 2020
  25. Junio C HamanoOct 26, 2020
  26. sideband: diagnose more incoming packet anomaliesJeff King, Oct 27, 2020
  27. Jeff KingOct 27, 2020
  28. Junio C HamanoOct 27, 2020
  29. Jeff KingOct 27, 2020
  30. Junio C HamanoOct 27, 2020
  31. Jeff KingOct 28, 2020
  32. Jeff KingOct 27, 2020
  33. Junio C HamanoOct 27, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.