diff --git a/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp b/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp --- a/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp +++ b/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp @@ -2,7 +2,7 @@ /// allow this test to also run on Windows (which can't be done for the /// debuginfo variant). -// RUN: %clangxx_asan -O2 %S/global-location.cpp -o %t -Wl,-S +// RUN: %clangxx_asan -O2 %S/global-location.cpp -o %t %if target={{.*-windows-msvc.*}} %{ -Wl,/DEBUG:NONE %} %else %{ -Wl,-S %} // RUN: not %run %t g 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=GLOB-NO-G // RUN: not %run %t c 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CLASS_STATIC-NO-G // RUN: not %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=FUNC_STATIC-NO-G @@ -11,12 +11,9 @@ /// Solaris ld -S has different semantics. // XFAIL: target={{.*solaris.*}} -/// MSVC linker doesn't support `-S`. -// UNSUPPORTED: target={{.*windows.*}} - // CHECK: AddressSanitizer: global-buffer-overflow // CLASS_STATIC-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}C::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40 // GLOB-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}global{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40 -// FUNC_STATIC-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}main::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40 +// FUNC_STATIC-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}main{{.*}}::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40 // LITERAL-NO-G: 0x{{.*}} is located 0 bytes after global variable {{.*}} defined in '{{.*}}global-location.cpp' {{.*}} of size 11 // CHECK: SUMMARY: AddressSanitizer: global-buffer-overflow diff --git a/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp b/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp --- a/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp +++ b/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp @@ -1,12 +1,11 @@ -// RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s -// RUN: %clangxx_asan -O2 %s -o %t && %env_asan_opts=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s -// RUN: %clangxx_asan -O0 %s -o %t -fsanitize-address-use-after-return=always && not %run %t 2>&1 | FileCheck %s -// RUN: %clangxx_asan -O2 %s -o %t -fsanitize-address-use-after-return=always && not %run %t 2>&1 | FileCheck %s -// XFAIL: target={{.*windows-msvc.*}} +// Most Windows linkers set stack size default to 1 MB. Bump it up to 8 MB. +// DEFINE: %{stack} = %if target={{.*-windows-gnu}} %{ -Wl,--stack,8388608 %} \ +// DEFINE: %if target={{.*-windows-msvc.*}} %{ -Wl,/STACK:8388608 %} -// FIXME: Investigate failure on MinGW. MinGW ASAN produces a different report: -// stack-overflow on address -// XFAIL: target={{.*-windows-gnu}} +// RUN: %clangxx_asan %{stack} -O0 %s -o %t && %env_asan_opts=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan %{stack} -O2 %s -o %t && %env_asan_opts=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan %{stack} -O0 %s -o %t -fsanitize-address-use-after-return=always && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan %{stack} -O2 %s -o %t -fsanitize-address-use-after-return=always && not %run %t 2>&1 | FileCheck %s // FIXME: Fix this test under GCC. // REQUIRES: Clang @@ -19,6 +18,9 @@ #include #include #include +#ifdef _WIN32 +# include +#endif __attribute__((noinline)) char *pretend_to_do_something(char *x) { @@ -44,10 +46,10 @@ } int main(int argc, char **argv) { -#ifdef _MSC_VER - // FIXME: This test crashes on Windows and raises a dialog. Avoid running it - // in addition to XFAILing it. - return 42; +#ifdef _WIN32 + // Prevent the crash dialog from showing in case something bad like a stack + // overflow happens. + SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); #endif int n_iter = argc >= 2 ? atoi(argv[1]) : 1000;