{"thread":{"id":"46398","subject":"[PATCH] t: handle EOF in test_copy_bytes()","startedAt":"2017-07-16T10:45:38Z","lastAt":"2017-07-16T11:21:07Z","messageCount":4,"participants":["Jeff King","René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"324609","messageId":"20170716104532.zyni62mvzz6rglu6@sigill.intra.peff.net","threadId":"46398","inReplyTo":null,"subject":"[PATCH] t: handle EOF in test_copy_bytes()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-07-16T10:45:32Z","receivedAt":"2017-07-16T10:45:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The test_copy_bytes() function claims to read up to N bytes,\nor until it gets EOF. But we never handle EOF in our loop,\nand a short input will cause perl to go into an infinite\nloop of read() getting zero bytes.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI was playing with SANITIZE=undefined after René's patches to see how\nfar we had left to go. I forgot to turn off sha1dc, which causes most\nprograms to die due to the unaligned loads. That means git-archive in\nt5000 generates no output, triggering the bug. :)\n\n t/test-lib-functions.sh | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex db622c355..50a9a1d1c 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -999,6 +999,7 @@ test_copy_bytes () {\n \t\t\tmy $s;\n \t\t\tmy $nread = sysread(STDIN, $s, $len);\n \t\t\tdie \"cannot read: $!\" unless defined($nread);\n+\t\t\tlast unless $nread;\n \t\t\tprint $s;\n \t\t\t$len -= $nread;\n \t\t}\n-- \n2.14.0.rc0.452.gc10560834\n"},{"id":"324610","messageId":"20170716104718.i4nyphyzqh2mzhxt@sigill.intra.peff.net","threadId":"46398","inReplyTo":"20170716104532.zyni62mvzz6rglu6@sigill.intra.peff.net","subject":"Re: [PATCH] t: handle EOF in test_copy_bytes()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-07-16T10:47:19Z","receivedAt":"2017-07-16T10:47:24Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jul 16, 2017 at 06:45:32AM -0400, Jeff King wrote:\n\n> I was playing with SANITIZE=undefined after René's patches to see how\n> far we had left to go. I forgot to turn off sha1dc, which causes most\n> programs to die due to the unaligned loads. That means git-archive in\n> t5000 generates no output, triggering the bug. :)\n\nAnd I was pleased to see that after setting OPENSSL_SHA1, the answer to\n\"how far\" is \"we are there\". Yay.\n\n-Peff\n"},{"id":"324614","messageId":"c79eeaec-64e6-db27-d590-ab94a47394d1@web.de","threadId":"46398","inReplyTo":"20170716104718.i4nyphyzqh2mzhxt@sigill.intra.peff.net","subject":"Re: [PATCH] t: handle EOF in test_copy_bytes()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2017-07-16T11:10:50Z","receivedAt":"2017-07-16T11:11:00Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 16.07.2017 um 12:47 schrieb Jeff King:\n> On Sun, Jul 16, 2017 at 06:45:32AM -0400, Jeff King wrote:\n> \n>> I was playing with SANITIZE=undefined after René's patches to see how\n>> far we had left to go. I forgot to turn off sha1dc, which causes most\n>> programs to die due to the unaligned loads. That means git-archive in\n>> t5000 generates no output, triggering the bug. :)\n> \n> And I was pleased to see that after setting OPENSSL_SHA1, the answer to\n> \"how far\" is \"we are there\". Yay.\n\nTrue with GCC, but not with Clang 3.9.  A patch for alignment issues in\ndir.c is coming up..\n\nRené\n"},{"id":"324617","messageId":"20170716112100.gktc2ipxbidj6ca6@sigill.intra.peff.net","threadId":"46398","inReplyTo":"c79eeaec-64e6-db27-d590-ab94a47394d1@web.de","subject":"Re: [PATCH] t: handle EOF in test_copy_bytes()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-07-16T11:21:01Z","receivedAt":"2017-07-16T11:21:07Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jul 16, 2017 at 01:10:50PM +0200, René Scharfe wrote:\n\n> > And I was pleased to see that after setting OPENSSL_SHA1, the answer to\n> > \"how far\" is \"we are there\". Yay.\n> \n> True with GCC, but not with Clang 3.9.  A patch for alignment issues in\n> dir.c is coming up..\n\nGood to know that there are differences. I used clang for my sanitize\nruns for the past few years (because of issues I had with gcc's version\nin the 4.8 era), but just switched a week or two ago back to using gcc.\n\nMy impression is that clang is the primary platform for sanitizer\ndevelopment, and so it would probably produce better results. We _could_\nforce \"CC ?= clang\" when SANITIZE is set, but that's probably a bit\nunfriendly to people who only have gcc.\n\nFWIW, I just did an UBSan run with clang-5.0, and it comes up with only\nthe dir.c problem.\n\n-Peff\n"}]}