FileCheck mishandles buffering on Windows when Cygwin is on PATH? #20118
Labels
bugzilla
Issues migrated from bugzilla
test-suite
wontfix
Issue is real, but we can't or won't fix it. Not invalid
Extended Description
Steps to repro as of r208805:
Have LLVM+Clang+compiler-rt checkout on a Windows machine
Do a cmake/ninja build
Put cygwin at the end of your PATH like so:
$ set PATH=%PATH%;C:\cygwin\bin
Run
$ python bin\llvm-lit.py -v projects\compiler-rt\test\asan\32bitConfig\TestCases --filter=thread_stack
and make sure it passes
Apply the following simple patch to compiler-rt:
diff --git lib/sanitizer_common/sanitizer_win.cc lib/sanitizer_common/sanitizer_win.cc
index ec6ce99..f82f78e 100644
--- lib/sanitizer_common/sanitizer_win.cc
+++ lib/sanitizer_common/sanitizer_win.cc
@@ -304,6 +304,7 @@ uptr internal_write(fd_t fd, const void *buf, uptr count) {
}
DWORD ret;
if (WriteFile(output_stream, buf, count, &ret, 0))
return ret;
diff --git test/asan/TestCases/Windows/thread_stack_array_left_oob.cc test/asan/TestCases/Windows/thread_stack_array_left_oob.cc
index 31a58bb..e6db163 100644
--- test/asan/TestCases/Windows/thread_stack_array_left_oob.cc
+++ test/asan/TestCases/Windows/thread_stack_array_left_oob.cc
@@ -1,7 +1,7 @@
// RUN: %clangxx_asan -O0 %s -Fe%t 2>&1
// 'cat' is used below to work around FileCheck buffering bug which makes this
// test flaky. FIXME: file an issue.
-// RUN: not %run %t 2>&1 | cat | FileCheck %s
+// RUN: not %run %t 2>&1 | FileCheck %s
#include <windows.h>
I observe a failure like this:
Command Output (stderr):
projects/compiler-rt/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc:12:11: error: expected string not found in input
// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
^
:1:1: note: scanning from here
^
--
Testing Time: 5.02s
Failing Tests (1):
AddressSanitizer32 :: TestCases/Windows/thread_stack_array_left_oob.cc
It looks like the pipe between the binary and FileCheck gets interrupted without waiting for the writer process to finish/close it.
The text was updated successfully, but these errors were encountered: