diff --git a/compiler-rt/lib/asan/tests/asan_str_test.cpp b/compiler-rt/lib/asan/tests/asan_str_test.cpp --- a/compiler-rt/lib/asan/tests/asan_str_test.cpp +++ b/compiler-rt/lib/asan/tests/asan_str_test.cpp @@ -110,8 +110,16 @@ } #endif +// This test fails on MinGW-w64 because it still ships a static copy of strnlen +// despite it being available from UCRT. +#if defined(__MINGW32__) +# define MAYBE_StrNLenOOBTest DISABLED_StrNLenOOBTest +#else +# define MAYBE_StrNLenOOBTest StrNLenOOBTest +#endif + #if SANITIZER_TEST_HAS_STRNLEN -TEST(AddressSanitizer, StrNLenOOBTest) { +TEST(AddressSanitizer, MAYBE_StrNLenOOBTest) { size_t size = Ident(123); char *str = MallocAndMemsetString(size); // Normal strnlen calls. @@ -132,10 +140,10 @@ // This test fails with the WinASan dynamic runtime because we fail to intercept // strdup. -#if defined(_MSC_VER) && defined(_DLL) -#define MAYBE_StrDupOOBTest DISABLED_StrDupOOBTest +#if (defined(_MSC_VER) && defined(_DLL)) || defined(__MINGW32__) +# define MAYBE_StrDupOOBTest DISABLED_StrDupOOBTest #else -#define MAYBE_StrDupOOBTest StrDupOOBTest +# define MAYBE_StrDupOOBTest StrDupOOBTest #endif TEST(AddressSanitizer, MAYBE_StrDupOOBTest) { diff --git a/compiler-rt/lib/asan/tests/asan_test.cpp b/compiler-rt/lib/asan/tests/asan_test.cpp --- a/compiler-rt/lib/asan/tests/asan_test.cpp +++ b/compiler-rt/lib/asan/tests/asan_test.cpp @@ -203,8 +203,16 @@ TEST(AddressSanitizer, UAF_long_double) { if (sizeof(long double) == sizeof(double)) return; long double *p = Ident(new long double[10]); +#if defined(_WIN32) + // https://google.github.io/googletest/advanced.html#regular-expression-syntax + // GoogleTest's regular expression engine on Windows does not support `[]` + // brackets. + EXPECT_DEATH(Ident(p)[12] = 0, "WRITE of size 10"); + EXPECT_DEATH(Ident(p)[0] = Ident(p)[12], "READ of size 10"); +#else EXPECT_DEATH(Ident(p)[12] = 0, "WRITE of size 1[026]"); EXPECT_DEATH(Ident(p)[0] = Ident(p)[12], "READ of size 1[026]"); +#endif delete [] Ident(p); } diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h b/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h @@ -127,8 +127,8 @@ # define SANITIZER_TEST_HAS_PRINTF_L 0 #endif -#if !defined(_MSC_VER) -# define SANITIZER_TEST_HAS_STRNDUP 1 +#if !defined(_WIN32) +# define SANITIZER_TEST_HAS_STRNDUP 1 #else # define SANITIZER_TEST_HAS_STRNDUP 0 #endif diff --git a/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp b/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp --- a/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp @@ -4,6 +4,10 @@ // RUN: %env_asan_opts=coverage=1 %run ./test.exe // // RUN: %sancov print *.sancov | FileCheck %s + +// FIXME: Investigate failure on MinGW. +// XFAIL: target={{.*-windows-gnu}} + #include void foo() { fputs("FOO", stderr); } diff --git a/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp b/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp --- a/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp @@ -1,4 +1,14 @@ -// RUN: %clangxx_asan -O0 %s -o %t +// This test works on both MSVC and MinGW targets, but they require different +// build commands. By default we use DWARF debug info on MinGW and dbghelp does +// not support it, so we need to specify extra flags to get the compiler to +// generate PDB debug info. + +// The first build command is intended for MSVC target, which fails on MinGW. +// The second build command contains the flags required to get PDB debug info +// on a MinGW build, which fails on MSVC. + +// RUN: %clangxx_asan -O0 %s -o %t \ +// RUN: || %clangxx_asan -gcodeview -gcolumn-info -Wl,--pdb= -O0 %s -o %t -ldbghelp // RUN: %env_asan_opts=external_symbolizer_path=non-existent\\\\asdf not %run %t 2>&1 | FileCheck %s #include diff --git a/compiler-rt/test/asan/TestCases/atexit_stats.cpp b/compiler-rt/test/asan/TestCases/atexit_stats.cpp --- a/compiler-rt/test/asan/TestCases/atexit_stats.cpp +++ b/compiler-rt/test/asan/TestCases/atexit_stats.cpp @@ -6,6 +6,9 @@ // https://code.google.com/p/address-sanitizer/issues/detail?id=263 // UNSUPPORTED: android +// FIXME: Investigate failure on MinGW. +// XFAIL: target={{.*-windows-gnu}} + #include #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) #include diff --git a/compiler-rt/test/asan/TestCases/atoll_strict.c b/compiler-rt/test/asan/TestCases/atoll_strict.c --- a/compiler-rt/test/asan/TestCases/atoll_strict.c +++ b/compiler-rt/test/asan/TestCases/atoll_strict.c @@ -11,7 +11,7 @@ // RUN: %env_asan_opts=strict_string_checks=true not %run %t test3 2>&1 | FileCheck %s --check-prefix=CHECK3 // FIXME: Needs Windows interceptor. -// XFAIL: target={{.*windows-msvc.*}} +// XFAIL: target={{.*windows-(msvc.*|gnu)}} #include #include diff --git a/compiler-rt/test/asan/TestCases/frexpl_interceptor.cpp b/compiler-rt/test/asan/TestCases/frexpl_interceptor.cpp --- a/compiler-rt/test/asan/TestCases/frexpl_interceptor.cpp +++ b/compiler-rt/test/asan/TestCases/frexpl_interceptor.cpp @@ -2,6 +2,10 @@ // Test the frexpl() interceptor. +// FIXME: MinGW-w64 implements `frexpl()` as a static import, so the dynamic +// interceptor seems to not work. +// XFAIL: target={{.*-windows-gnu}} + #include #include #include diff --git a/compiler-rt/test/asan/TestCases/global-location.cpp b/compiler-rt/test/asan/TestCases/global-location.cpp --- a/compiler-rt/test/asan/TestCases/global-location.cpp +++ b/compiler-rt/test/asan/TestCases/global-location.cpp @@ -7,6 +7,9 @@ // COFF doesn't support debuginfo for globals. For the non-debuginfo tests, see global-location-nodebug.cpp. // XFAIL: target={{.*windows-msvc.*}} +// FIXME: Investigate failure on MinGW +// XFAIL: target={{.*-windows-gnu}} + // atos doesn't show source line numbers for global variables. // UNSUPPORTED: darwin 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 @@ -4,6 +4,10 @@ // RUN: %clangxx_asan -O2 %s -o %t -fsanitize-address-use-after-return=always && not %run %t 2>&1 | FileCheck %s // XFAIL: target={{.*windows-msvc.*}} +// FIXME: Investigate failure on MinGW. MinGW ASAN produces a different report: +// stack-overflow on address +// XFAIL: target={{.*-windows-gnu}} + // FIXME: Fix this test under GCC. // REQUIRES: Clang diff --git a/compiler-rt/test/asan/TestCases/init-order-atexit.cpp b/compiler-rt/test/asan/TestCases/init-order-atexit.cpp --- a/compiler-rt/test/asan/TestCases/init-order-atexit.cpp +++ b/compiler-rt/test/asan/TestCases/init-order-atexit.cpp @@ -7,6 +7,9 @@ // RUN: %clangxx_asan -O0 %s %p/Helpers/init-order-atexit-extra.cpp -o %t // RUN: %env_asan_opts=strict_init_order=true not %run %t 2>&1 | FileCheck %s +// FIXME: Investigate failure on MinGW +// XFAIL: target={{.*-windows-gnu}} + #include #include diff --git a/compiler-rt/test/asan/TestCases/printf-2.c b/compiler-rt/test/asan/TestCases/printf-2.c --- a/compiler-rt/test/asan/TestCases/printf-2.c +++ b/compiler-rt/test/asan/TestCases/printf-2.c @@ -6,7 +6,7 @@ // RUN: %env_asan_opts=replace_str=0:intercept_strlen=0:replace_intrin=0 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s // FIXME: printf is not intercepted on Windows yet. -// XFAIL: target={{.*windows-msvc.*}} +// XFAIL: target={{.*windows-(msvc.*|gnu)}} #include #include diff --git a/compiler-rt/test/asan/TestCases/printf-3.c b/compiler-rt/test/asan/TestCases/printf-3.c --- a/compiler-rt/test/asan/TestCases/printf-3.c +++ b/compiler-rt/test/asan/TestCases/printf-3.c @@ -4,7 +4,7 @@ // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s // FIXME: printf is not intercepted on Windows yet. -// XFAIL: target={{.*windows-msvc.*}} +// XFAIL: target={{.*windows-(msvc.*|gnu)}} // New Bionic rejects %n // https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336 diff --git a/compiler-rt/test/asan/TestCases/printf-5.c b/compiler-rt/test/asan/TestCases/printf-5.c --- a/compiler-rt/test/asan/TestCases/printf-5.c +++ b/compiler-rt/test/asan/TestCases/printf-5.c @@ -5,7 +5,7 @@ // RUN: %env_asan_opts=replace_intrin=0 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s // FIXME: printf is not intercepted on Windows yet. -// XFAIL: target={{.*windows-msvc.*}} +// XFAIL: target={{.*windows-(msvc.*|gnu)}} #include #include diff --git a/compiler-rt/test/asan/TestCases/strcasestr-1.c b/compiler-rt/test/asan/TestCases/strcasestr-1.c --- a/compiler-rt/test/asan/TestCases/strcasestr-1.c +++ b/compiler-rt/test/asan/TestCases/strcasestr-1.c @@ -6,7 +6,7 @@ // RUN: %env_asan_opts=intercept_strstr=false:replace_str=false %run %t 2>&1 // There's no interceptor for strcasestr on Windows -// XFAIL: target={{.*windows-msvc.*}} +// XFAIL: target={{.*windows-(msvc.*|gnu)}} #define _GNU_SOURCE #include diff --git a/compiler-rt/test/asan/TestCases/strcasestr-2.c b/compiler-rt/test/asan/TestCases/strcasestr-2.c --- a/compiler-rt/test/asan/TestCases/strcasestr-2.c +++ b/compiler-rt/test/asan/TestCases/strcasestr-2.c @@ -6,7 +6,7 @@ // RUN: %env_asan_opts=intercept_strstr=false:replace_str=false:intercept_strlen=false %run %t 2>&1 // There's no interceptor for strcasestr on Windows -// XFAIL: target={{.*windows-msvc.*}} +// XFAIL: target={{.*windows-(msvc.*|gnu)}} #define _GNU_SOURCE #include diff --git a/compiler-rt/test/asan/TestCases/strcasestr_strict.c b/compiler-rt/test/asan/TestCases/strcasestr_strict.c --- a/compiler-rt/test/asan/TestCases/strcasestr_strict.c +++ b/compiler-rt/test/asan/TestCases/strcasestr_strict.c @@ -4,7 +4,7 @@ // RUN: %env_asan_opts=strict_string_checks=true not %run %t 2>&1 | FileCheck %s // There's no interceptor for strcasestr on Windows -// XFAIL: target={{.*windows-msvc.*}} +// XFAIL: target={{.*windows-(msvc.*|gnu)}} #define _GNU_SOURCE #include diff --git a/compiler-rt/test/asan/TestCases/strncasecmp_strict.c b/compiler-rt/test/asan/TestCases/strncasecmp_strict.c --- a/compiler-rt/test/asan/TestCases/strncasecmp_strict.c +++ b/compiler-rt/test/asan/TestCases/strncasecmp_strict.c @@ -14,7 +14,7 @@ // RUN: %env_asan_opts=strict_string_checks=false %run %t i 2>&1 // RUN: %env_asan_opts=strict_string_checks=true not %run %t i 2>&1 | FileCheck %s -// XFAIL: target={{.*windows-msvc.*}} +// XFAIL: target={{.*windows-(msvc.*|gnu)}} #include #include diff --git a/compiler-rt/test/asan/TestCases/strtoll_strict.c b/compiler-rt/test/asan/TestCases/strtoll_strict.c --- a/compiler-rt/test/asan/TestCases/strtoll_strict.c +++ b/compiler-rt/test/asan/TestCases/strtoll_strict.c @@ -24,7 +24,7 @@ // FIXME: Enable strtoll interceptor. // REQUIRES: shadow-scale-3 -// XFAIL: target={{.*windows-msvc.*}} +// XFAIL: target={{.*windows-(msvc.*|gnu)}} #include #include diff --git a/compiler-rt/test/asan/TestCases/time_interceptor.cpp b/compiler-rt/test/asan/TestCases/time_interceptor.cpp --- a/compiler-rt/test/asan/TestCases/time_interceptor.cpp +++ b/compiler-rt/test/asan/TestCases/time_interceptor.cpp @@ -2,8 +2,8 @@ // Test the time() interceptor. -// There's no interceptor for time() on Windows yet. -// XFAIL: target={{.*windows-msvc.*}} +// FIXME: There's no interceptor for time() on Windows yet. +// XFAIL: target={{.*windows-(msvc.*|gnu)}} #include #include