Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileCheck mishandles buffering on Windows when Cygwin is on PATH? #20118

Closed
timurrrr opened this issue May 14, 2014 · 6 comments
Closed

FileCheck mishandles buffering on Windows when Cygwin is on PATH? #20118

timurrrr opened this issue May 14, 2014 · 6 comments
Labels
bugzilla Issues migrated from bugzilla test-suite wontfix Issue is real, but we can't or won't fix it. Not invalid

Comments

@timurrrr
Copy link
Contributor

Bugzilla Link 19744
Resolution WONTFIX
Resolved on May 27, 2014 15:47
Version trunk
OS Windows NT
CC @majnemer,@rnk

Extended Description

Steps to repro as of r208805:

  1. Have LLVM+Clang+compiler-rt checkout on a Windows machine

  2. Do a cmake/ninja build

  3. Put cygwin at the end of your PATH like so:
    $ set PATH=%PATH%;C:\cygwin\bin

  4. Run
    $ python bin\llvm-lit.py -v projects\compiler-rt\test\asan\32bitConfig\TestCases --filter=thread_stack
    and make sure it passes

  5. 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>

  1. 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]+]]
^
: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.

@timurrrr
Copy link
Contributor Author

FTR, I can't repro that without Cygwin on the PATH.

@timurrrr
Copy link
Contributor Author

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?

@timurrrr
Copy link
Contributor Author

Any ideas?

@llvmbot
Copy link
Collaborator

llvmbot commented May 26, 2014

IMO, don't add cygwin in %PATH%. May I mark this as INVALID?

@timurrrr
Copy link
Contributor Author

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.

@rnk
Copy link
Collaborator

rnk commented May 27, 2014

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.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
@Quuxplusone Quuxplusone added the wontfix Issue is real, but we can't or won't fix it. Not invalid label Jan 20, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla test-suite wontfix Issue is real, but we can't or won't fix it. Not invalid
Projects
None yet
Development

No branches or pull requests

4 participants