Subject: Re: [Bug] Test 1450.91 Fails on NonStop

From: Junio C Hamano <[email-masked]>
Date: Wed, 15 Feb 2023 11:10:14 -0800

<[email-masked]> writes:

> So, this looks like we do not have to hold the 2.39.2 release for this problem. I will run the packaging job for the platform release.
>
> + test-tool genzeros 104857601
> fatal: write(): Invalid function argument
>
> That explains it. We had to push the use of xwrite() because of
> issues associated with writing large buffers exceeding through
> write(). We could use MAX_IO_SIZE to limit the write size (at
> least on NonStop) into acceptable chunks.

True.

Curious that this use of write(2) is from late 2021 and its uses in
tests came from the same era (e.g. t1051 has two calls added in the
same timeperiod).  So it is nothing new even to your platform, I
suspect.

There are a handful of raw write() in reftable implementation whose
size I am not sure about (and I am not touching), and a deliberate
use of it in trace2/tr2_dst.c that is well explained (and I do not
think touching is a good idea).  Everything else looks like they are
aware that they are making a short write, but some of them might
still want to become xwrite() to benefit from auto retrying a short
write (which I didn't check).

In any case, I think the attached is a sensible first step to have.

 t/helper/test-genzeros.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git c/t/helper/test-genzeros.c w/t/helper/test-genzeros.c
index 8ca988d621..9a1d3ee221 100644
--- c/t/helper/test-genzeros.c
+++ w/t/helper/test-genzeros.c
@@ -17,12 +17,12 @@ int cmd__genzeros(int argc, const char **argv)
 
 	/* Writing out individual NUL bytes is slow... */
 	while (count < 0)
-		if (write(1, zeros, ARRAY_SIZE(zeros)) < 0)
+		if (xwrite(1, zeros, ARRAY_SIZE(zeros)) < 0)
 			return -1;
 
 	while (count > 0) {
-		n = write(1, zeros, count < ARRAY_SIZE(zeros) ?
-			  count : ARRAY_SIZE(zeros));
+		n = xwrite(1, zeros, count < ARRAY_SIZE(zeros) ?
+			   count : ARRAY_SIZE(zeros));
 
 		if (n < 0)
 			return -1;