From 00203bc60bfb956c6969d9a673c1f55f3ed09e1b Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 19 Feb 2016 17:30:38 +0000 Subject: [PATCH] [Windows] Add 10s timeout to some WaitForSingleObject calls I ran the test suite yesterday and when I came back this morning the queue_user_work_item.cc test was hung. This could be why the sanitizer-windows buildbot keeps randomly timing out. I updated all the usages of WaitForSingleObject involving threading events. I'm assuming the API can reliably wait for subprocesses, which is what the majority of call sites use it for. While I'm at it, we can simplify some EH tests now that clang can compile C++ EH. llvm-svn: 261338 --- .../asan/TestCases/Windows/bind_io_completion_callback.cc | 8 ++------ .../test/asan/TestCases/Windows/queue_user_work_item.cc | 13 +++++++------ .../asan/TestCases/Windows/queue_user_work_item_report.cc | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/compiler-rt/test/asan/TestCases/Windows/bind_io_completion_callback.cc b/compiler-rt/test/asan/TestCases/Windows/bind_io_completion_callback.cc index c062a79..44b92ab 100644 --- a/compiler-rt/test/asan/TestCases/Windows/bind_io_completion_callback.cc +++ b/compiler-rt/test/asan/TestCases/Windows/bind_io_completion_callback.cc @@ -6,8 +6,7 @@ // the rest is built with Clang. This represents the typical scenario when we // build a large project using "clang-cl -fallback -fsanitize=address". // -// RUN: cl -c %s -Fo%t.obj -// RUN: %clangxx_asan -o %t.exe %s %t.obj +// RUN: %clangxx_asan %s -o %t.exe // RUN: %run %t.exe 2>&1 | FileCheck %s #include @@ -15,7 +14,6 @@ void ThrowAndCatch(); -#if !defined(__clang__) __declspec(noinline) void Throw() { fprintf(stderr, "Throw\n"); @@ -32,7 +30,6 @@ void ThrowAndCatch() { // CHECK: Catch } } -#else char buffer[65536]; HANDLE done; @@ -62,9 +59,8 @@ int main(int argc, char **argv) { GetLastError() != ERROR_IO_PENDING) return 4; - if (WAIT_OBJECT_0 != WaitForSingleObject(done, INFINITE)) + if (WAIT_OBJECT_0 != WaitForSingleObject(done, 10 * 1000)) return 5; fprintf(stderr, "Done!\n"); // CHECK: Done! } -#endif diff --git a/compiler-rt/test/asan/TestCases/Windows/queue_user_work_item.cc b/compiler-rt/test/asan/TestCases/Windows/queue_user_work_item.cc index d99ea6f..2a0b622 100644 --- a/compiler-rt/test/asan/TestCases/Windows/queue_user_work_item.cc +++ b/compiler-rt/test/asan/TestCases/Windows/queue_user_work_item.cc @@ -6,8 +6,7 @@ // the rest is built with Clang. This represents the typical scenario when we // build a large project using "clang-cl -fallback -fsanitize=address". // -// RUN: cl -c %s -Fo%t.obj -// RUN: %clangxx_asan -o %t.exe %s %t.obj +// RUN: %clangxx_asan %s -o %t.exe // RUN: %run %t.exe 2>&1 | FileCheck %s #include @@ -15,7 +14,6 @@ void ThrowAndCatch(); -#if !defined(__clang__) __declspec(noinline) void Throw() { fprintf(stderr, "Throw\n"); @@ -32,7 +30,6 @@ void ThrowAndCatch() { // CHECK: Catch } } -#else HANDLE done; @@ -47,9 +44,13 @@ int main(int argc, char **argv) { if (!done) return 1; QueueUserWorkItem(&work_item, nullptr, 0); - if (WAIT_OBJECT_0 != WaitForSingleObject(done, INFINITE)) + unsigned wait_result = WaitForSingleObject(done, 10 * 1000); + if (wait_result == WAIT_ABANDONED) + fprintf(stderr, "Timed out\n"); + if (wait_result != WAIT_OBJECT_0) { + fprintf(stderr, "Wait for work item failed\n"); return 2; + } fprintf(stderr, "Done!\n"); // CHECK: Done! } -#endif diff --git a/compiler-rt/test/asan/TestCases/Windows/queue_user_work_item_report.cc b/compiler-rt/test/asan/TestCases/Windows/queue_user_work_item_report.cc index f0d3d3e..e500a91 100644 --- a/compiler-rt/test/asan/TestCases/Windows/queue_user_work_item_report.cc +++ b/compiler-rt/test/asan/TestCases/Windows/queue_user_work_item_report.cc @@ -24,6 +24,6 @@ int main(int argc, char **argv) { return 1; // CHECK-NOT: Thread T1 created QueueUserWorkItem(&work_item, nullptr, 0); - if (WAIT_OBJECT_0 != WaitForSingleObject(done, INFINITE)) + if (WAIT_OBJECT_0 != WaitForSingleObject(done, 10 * 1000)) return 2; } -- 2.7.4