}
#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.
// 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) {
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);
}
# 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
// 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 <stdio.h>
void foo() { fputs("FOO", stderr); }
-// 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 <windows.h>
// https://code.google.com/p/address-sanitizer/issues/detail?id=263
// UNSUPPORTED: android
+// FIXME: Investigate failure on MinGW.
+// XFAIL: target={{.*-windows-gnu}}
+
#include <stdlib.h>
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
#include <malloc.h>
// 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 <assert.h>
#include <stdlib.h>
// 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 <math.h>
#include <stdio.h>
#include <stdlib.h>
// 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
// 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
// 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 <stdio.h>
#include <stdlib.h>
// 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 <stdio.h>
#include <stdlib.h>
// 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
// 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 <stdio.h>
#include <string.h>
// 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 <assert.h>
// 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 <assert.h>
// 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 <assert.h>
// 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 <assert.h>
#include <stdlib.h>
// FIXME: Enable strtoll interceptor.
// REQUIRES: shadow-scale-3
-// XFAIL: target={{.*windows-msvc.*}}
+// XFAIL: target={{.*windows-(msvc.*|gnu)}}
#include <assert.h>
#include <stdlib.h>
// 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 <stdio.h>
#include <stdlib.h>