* [PATCH] t: handle EOF in test_copy_bytes()
@ 2017-07-16 10:45 Jeff King
2017-07-16 10:47 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2017-07-16 10:45 UTC (permalink / raw)
To: git; +Cc: René Scharfe
The test_copy_bytes() function claims to read up to N bytes,
or until it gets EOF. But we never handle EOF in our loop,
and a short input will cause perl to go into an infinite
loop of read() getting zero bytes.
Signed-off-by: Jeff King <peff@peff.net>
---
I was playing with SANITIZE=undefined after René's patches to see how
far we had left to go. I forgot to turn off sha1dc, which causes most
programs to die due to the unaligned loads. That means git-archive in
t5000 generates no output, triggering the bug. :)
t/test-lib-functions.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index db622c355..50a9a1d1c 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -999,6 +999,7 @@ test_copy_bytes () {
my $s;
my $nread = sysread(STDIN, $s, $len);
die "cannot read: $!" unless defined($nread);
+ last unless $nread;
print $s;
$len -= $nread;
}
--
2.14.0.rc0.452.gc10560834
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] t: handle EOF in test_copy_bytes()
2017-07-16 10:45 [PATCH] t: handle EOF in test_copy_bytes() Jeff King
@ 2017-07-16 10:47 ` Jeff King
2017-07-16 11:10 ` René Scharfe
0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2017-07-16 10:47 UTC (permalink / raw)
To: git; +Cc: René Scharfe
On Sun, Jul 16, 2017 at 06:45:32AM -0400, Jeff King wrote:
> I was playing with SANITIZE=undefined after René's patches to see how
> far we had left to go. I forgot to turn off sha1dc, which causes most
> programs to die due to the unaligned loads. That means git-archive in
> t5000 generates no output, triggering the bug. :)
And I was pleased to see that after setting OPENSSL_SHA1, the answer to
"how far" is "we are there". Yay.
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] t: handle EOF in test_copy_bytes()
2017-07-16 10:47 ` Jeff King
@ 2017-07-16 11:10 ` René Scharfe
2017-07-16 11:21 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: René Scharfe @ 2017-07-16 11:10 UTC (permalink / raw)
To: Jeff King, git
Am 16.07.2017 um 12:47 schrieb Jeff King:
> On Sun, Jul 16, 2017 at 06:45:32AM -0400, Jeff King wrote:
>
>> I was playing with SANITIZE=undefined after René's patches to see how
>> far we had left to go. I forgot to turn off sha1dc, which causes most
>> programs to die due to the unaligned loads. That means git-archive in
>> t5000 generates no output, triggering the bug. :)
>
> And I was pleased to see that after setting OPENSSL_SHA1, the answer to
> "how far" is "we are there". Yay.
True with GCC, but not with Clang 3.9. A patch for alignment issues in
dir.c is coming up..
René
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] t: handle EOF in test_copy_bytes()
2017-07-16 11:10 ` René Scharfe
@ 2017-07-16 11:21 ` Jeff King
0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2017-07-16 11:21 UTC (permalink / raw)
To: René Scharfe; +Cc: git
On Sun, Jul 16, 2017 at 01:10:50PM +0200, René Scharfe wrote:
> > And I was pleased to see that after setting OPENSSL_SHA1, the answer to
> > "how far" is "we are there". Yay.
>
> True with GCC, but not with Clang 3.9. A patch for alignment issues in
> dir.c is coming up..
Good to know that there are differences. I used clang for my sanitize
runs for the past few years (because of issues I had with gcc's version
in the 4.8 era), but just switched a week or two ago back to using gcc.
My impression is that clang is the primary platform for sanitizer
development, and so it would probably produce better results. We _could_
force "CC ?= clang" when SANITIZE is set, but that's probably a bit
unfriendly to people who only have gcc.
FWIW, I just did an UBSan run with clang-5.0, and it comes up with only
the dir.c problem.
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-16 11:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-16 10:45 [PATCH] t: handle EOF in test_copy_bytes() Jeff King
2017-07-16 10:47 ` Jeff King
2017-07-16 11:10 ` René Scharfe
2017-07-16 11:21 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox