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

From: <[email-masked]>
Date: Wed, 15 Feb 2023 14:41:43 -0500

On Wednesday, February 15, 2023 2:10 PM, Junio C Hamano wrote:
><[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.

I have been looking at the past log (pre-2.39) and this test has not failed
previously - although git blame on t1450 shows 6-Feb-2023, so that might be
why I've not seen this previously. It is possible test-genzeros was not used
in this way previously.

>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).

I would not want to touch those either, although I do keep an eye out for
new write() usage and whine about it if I notice. ;-)

>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;

This works well as a fix. Please go with it with my blessing.
--Randall