<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - FileCheck mishandles buffering on Windows when Cygwin is on PATH?"
   href="http://llvm.org/bugs/show_bug.cgi?id=19744">19744</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>FileCheck mishandles buffering on Windows when Cygwin is on PATH?
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Test Suite
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>lit
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>timurrrr@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>daniel@zuster.org, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>