Steps to repro as of r208805: 1) Have LLVM+Clang+compiler-rt checkout on a Windows machine 2) Do a cmake/ninja build 4) Put cygwin at the end of your PATH like so: $ set PATH=%PATH%;C:\cygwin\bin 3) Run $ python bin\llvm-lit.py -v projects\compiler-rt\test\asan\32bitConfig\TestCases --filter=thread_stack and make sure it passes 4) 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; + Sleep(100); // Make the failure stable rather than flaky. 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> 5) Run the same test again. 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]+]] ^ <stdin>: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.
FTR, I can't repro that without Cygwin on the PATH.
Alp wrote: > Have you tried this test with and without the lit integrated shell? > That seems a more likely culprit than FileCheck. Did you mean with/without Cygwin? (see comment 1) Or should I pass some particular flag to lit?
Any ideas?
IMO, don't add cygwin in %PATH%. May I mark this as INVALID?
Ah, ok http://llvm.org/docs/GettingStartedVS.html now says "You will need GnuWin32 tools, too." For some historical reason I believed it's Cygwin that's required to run the tests on Windows.
I've previously been able to run these tests with Cygwin tools and mostly everything works as long as you don't use Cygwin *bash*. Instead, we use lit's shell interpreter, which works pretty well. I'm going to try check-asan after all the cat removing commits and share my results.