forked from OSchip/llvm-project
UBSan: Enable runtime library tests on Windows, and get most tests passing.
Specifically: - Disable int128 tests on Windows, as MSVC cl.exe does not support int128, so we might not have been able to build the runtime with int128 support. - XFAIL the vptr tests as we lack Microsoft ABI support. - XFAIL enum.cpp as UBSan fails to add the correct instrumentation code for some reason. - Modify certain tests that build executables multiple times to use unique names for each executable. This works around a race condition observed on Windows. - Implement IsAccessibleMemoryRange for Windows to fix the last misaligned.cpp test. - Introduce a substitution for testing crashes on Windows using KillTheDoctor. Differential Revision: http://reviews.llvm.org/D10864 llvm-svn: 241303
This commit is contained in:
parent
bfaf7e15d1
commit
a68d90fa52
|
@ -333,6 +333,9 @@ if(APPLE AND SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.9")
|
||||||
# Mac OS X prior to 10.9 had problems with exporting symbols from
|
# Mac OS X prior to 10.9 had problems with exporting symbols from
|
||||||
# libc++/libc++abi.
|
# libc++/libc++abi.
|
||||||
set(SANITIZER_CAN_USE_CXXABI FALSE)
|
set(SANITIZER_CAN_USE_CXXABI FALSE)
|
||||||
|
elseif(WIN32)
|
||||||
|
# We do not currently support the Microsoft C++ ABI.
|
||||||
|
set(SANITIZER_CAN_USE_CXXABI FALSE)
|
||||||
else()
|
else()
|
||||||
set(SANITIZER_CAN_USE_CXXABI TRUE)
|
set(SANITIZER_CAN_USE_CXXABI TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -35,7 +35,9 @@ namespace __sanitizer {
|
||||||
|
|
||||||
// --------------------- sanitizer_common.h
|
// --------------------- sanitizer_common.h
|
||||||
uptr GetPageSize() {
|
uptr GetPageSize() {
|
||||||
return 1U << 14; // FIXME: is this configurable?
|
// FIXME: there is an API for getting the system page size (GetSystemInfo or
|
||||||
|
// GetNativeSystemInfo), but if we use it here we get test failures elsewhere.
|
||||||
|
return 1U << 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
uptr GetMmapGranularity() {
|
uptr GetMmapGranularity() {
|
||||||
|
@ -615,7 +617,27 @@ bool IsDeadlySignal(int signum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsAccessibleMemoryRange(uptr beg, uptr size) {
|
bool IsAccessibleMemoryRange(uptr beg, uptr size) {
|
||||||
// FIXME: Actually implement this function.
|
SYSTEM_INFO si;
|
||||||
|
GetNativeSystemInfo(&si);
|
||||||
|
uptr page_size = si.dwPageSize;
|
||||||
|
uptr page_mask = ~(page_size - 1);
|
||||||
|
|
||||||
|
for (uptr page = beg & page_mask, end = (beg + size - 1) & page_mask;
|
||||||
|
page <= end;) {
|
||||||
|
MEMORY_BASIC_INFORMATION info;
|
||||||
|
if (VirtualQuery((LPCVOID)page, &info, sizeof(info)) != sizeof(info))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (info.Protect == 0 || info.Protect == PAGE_NOACCESS ||
|
||||||
|
info.Protect == PAGE_EXECUTE)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (info.RegionSize == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
page += info.RegionSize;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@ if(NOT ANDROID)
|
||||||
if (COMPILER_RT_HAS_PROFILE)
|
if (COMPILER_RT_HAS_PROFILE)
|
||||||
list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
|
list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
|
||||||
endif()
|
endif()
|
||||||
|
if (WIN32)
|
||||||
|
list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS SanitizerLintCheck)
|
list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS SanitizerLintCheck)
|
||||||
|
|
|
@ -80,6 +80,15 @@ config.substitutions.append( ('%run', config.emulator) )
|
||||||
# Define CHECK-%os to check for OS-dependent output.
|
# Define CHECK-%os to check for OS-dependent output.
|
||||||
config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))
|
config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))
|
||||||
|
|
||||||
|
if config.host_os == 'Windows':
|
||||||
|
# FIXME: This isn't quite right. Specifically, it will succeed if the program
|
||||||
|
# does not crash but exits with a non-zero exit code. We ought to merge
|
||||||
|
# KillTheDoctor and not --crash to make the latter more useful and remove the
|
||||||
|
# need for this substitution.
|
||||||
|
config.substitutions.append( ("%expect_crash ", "not KillTheDoctor ") )
|
||||||
|
else:
|
||||||
|
config.substitutions.append( ("%expect_crash ", "not --crash ") )
|
||||||
|
|
||||||
# Add supported compiler_rt architectures to a list of available features.
|
# Add supported compiler_rt architectures to a list of available features.
|
||||||
compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
|
compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
|
||||||
if compiler_rt_arch:
|
if compiler_rt_arch:
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
# define BYTE_ORDER _BYTE_ORDER
|
# define BYTE_ORDER _BYTE_ORDER
|
||||||
# define BIG_ENDIAN _BIG_ENDIAN
|
# define BIG_ENDIAN _BIG_ENDIAN
|
||||||
# define LITTLE_ENDIAN _LITTLE_ENDIAN
|
# define LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
# define BYTE_ORDER 0
|
||||||
|
# define BIG_ENDIAN 1
|
||||||
|
# define LITTLE_ENDIAN 0
|
||||||
#else
|
#else
|
||||||
# include <endian.h>
|
# include <endian.h>
|
||||||
# define BYTE_ORDER __BYTE_ORDER
|
# define BYTE_ORDER __BYTE_ORDER
|
||||||
|
@ -118,7 +122,7 @@ int main(int argc, char **argv) {
|
||||||
// Integer -> floating point overflow.
|
// Integer -> floating point overflow.
|
||||||
case '6': {
|
case '6': {
|
||||||
// CHECK-6: {{runtime error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'|__int128 not supported}}
|
// CHECK-6: {{runtime error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'|__int128 not supported}}
|
||||||
#ifdef __SIZEOF_INT128__
|
#if defined(__SIZEOF_INT128__) && !defined(_WIN32)
|
||||||
static int test_int = (float)(FloatMaxAsUInt128 + 1);
|
static int test_int = (float)(FloatMaxAsUInt128 + 1);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// RUN: %clangxx -DADD_I32 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
|
// RUN: %clangxx -DADD_I32 -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
|
||||||
// RUN: %clangxx -DADD_I64 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
|
// RUN: %clangxx -DADD_I64 -fsanitize=signed-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
|
||||||
// RUN: %clangxx -DADD_I128 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
|
// RUN: %clangxx -DADD_I128 -fsanitize=signed-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -22,7 +22,7 @@ int main() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ADD_I128
|
#ifdef ADD_I128
|
||||||
# ifdef __SIZEOF_INT128__
|
# if defined(__SIZEOF_INT128__) && !defined(_WIN32)
|
||||||
(void)((__int128_t(1) << 126) + (__int128_t(1) << 126));
|
(void)((__int128_t(1) << 126) + (__int128_t(1) << 126));
|
||||||
# else
|
# else
|
||||||
puts("__int128 not supported");
|
puts("__int128 not supported");
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// RUN: %clangxx -fsanitize=float-divide-by-zero -DDIVIDEND=1.5 %s -o %t && %run %t 2>&1 | FileCheck %s
|
// RUN: %clangxx -fsanitize=float-divide-by-zero -DDIVIDEND=1.5 %s -o %t && %run %t 2>&1 | FileCheck %s
|
||||||
// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND='intmax(123)' %s -o %t && %run %t 2>&1 | FileCheck %s
|
// RUN: %clangxx -fsanitize=integer-divide-by-zero -DDIVIDEND='intmax(123)' %s -o %t && %run %t 2>&1 | FileCheck %s
|
||||||
|
|
||||||
#ifdef __SIZEOF_INT128__
|
#if defined(__SIZEOF_INT128__) && !defined(_WIN32)
|
||||||
typedef __int128 intmax;
|
typedef __int128 intmax;
|
||||||
#else
|
#else
|
||||||
typedef long long intmax;
|
typedef long long intmax;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// RUN: %clangxx -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=PLUS
|
// RUN: %clangxx -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=PLUS
|
||||||
// RUN: %clangxx -DOP=++n -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=PLUS
|
// RUN: %clangxx -DOP=++n -fsanitize=signed-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=PLUS
|
||||||
// RUN: %clangxx -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=MINUS
|
// RUN: %clangxx -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=MINUS
|
||||||
// RUN: %clangxx -DOP=--m -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=MINUS
|
// RUN: %clangxx -DOP=--m -fsanitize=signed-integer-overflow %s -o %t4 && %run %t4 2>&1 | FileCheck %s --check-prefix=MINUS
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECKS
|
// RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECKS
|
||||||
// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECKU
|
// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECKU
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// CHECKS-NOT: runtime error
|
// CHECKS-NOT: runtime error
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
|
// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t1 && not %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
|
||||||
// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
|
// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t2 && not %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-LSH_OVERFLOW
|
||||||
// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
|
// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t3 && not %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
|
||||||
// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
|
// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t4 && not %run %t4 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
|
||||||
// RUN: %clangxx -DTOO_LOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
|
// RUN: %clangxx -DTOO_LOW -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t5 && not %run %t5 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
|
||||||
// RUN: %clangxx -DTOO_LOW -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
|
// RUN: %clangxx -DTOO_LOW -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t6 && not %run %t6 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_LOW
|
||||||
// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
|
// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t7 && not %run %t7 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
|
||||||
// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
|
// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t8 && not %run %t8 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
|
||||||
// RUN: %clangxx -DTOO_HIGH -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
|
// RUN: %clangxx -DTOO_HIGH -DOP='<<=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t9 && not %run %t9 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
|
||||||
// RUN: %clangxx -DTOO_HIGH -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
|
// RUN: %clangxx -DTOO_HIGH -DOP='>>=' -fsanitize=shift -fno-sanitize-recover=shift %s -o %t10 && not %run %t10 2>&1 | FileCheck %s --check-prefix=CHECK-TOO_HIGH
|
||||||
|
|
||||||
// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && %run %t
|
// RUN: %clangxx -DLSH_OVERFLOW -DOP='<<' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t12 && %run %t12
|
||||||
// RUN: %clangxx -DLSH_OVERFLOW -DOP='>>' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t && %run %t
|
// RUN: %clangxx -DLSH_OVERFLOW -DOP='>>' -fsanitize=shift-exponent -fno-sanitize-recover=shift %s -o %t13 && %run %t13
|
||||||
// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
|
// RUN: %clangxx -DTOO_LOW -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t14 && %run %t14
|
||||||
// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
|
// RUN: %clangxx -DTOO_LOW -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t15 && %run %t15
|
||||||
// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
|
// RUN: %clangxx -DTOO_HIGH -DOP='<<' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t16 && %run %t16
|
||||||
// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t && %run %t
|
// RUN: %clangxx -DTOO_HIGH -DOP='>>' -fsanitize=shift-base -fno-sanitize-recover=shift %s -o %t17 && %run %t17
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// RUN: %clangxx -DSUB_I32 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
|
// RUN: %clangxx -DSUB_I32 -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
|
||||||
// RUN: %clangxx -DSUB_I64 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
|
// RUN: %clangxx -DSUB_I64 -fsanitize=signed-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
|
||||||
// RUN: %clangxx -DSUB_I128 -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
|
// RUN: %clangxx -DSUB_I128 -fsanitize=signed-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -21,7 +21,7 @@ int main() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SUB_I128
|
#ifdef SUB_I128
|
||||||
# ifdef __SIZEOF_INT128__
|
# if defined(__SIZEOF_INT128__) && !defined(_WIN32)
|
||||||
(void)(-(__int128_t(1) << 126) - (__int128_t(1) << 126) - 1);
|
(void)(-(__int128_t(1) << 126) - (__int128_t(1) << 126) - 1);
|
||||||
# else
|
# else
|
||||||
puts("__int128 not supported");
|
puts("__int128 not supported");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// RUN: %clangxx -DADD_I32 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
|
// RUN: %clangxx -DADD_I32 -fsanitize=unsigned-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I32
|
||||||
// RUN: %clangxx -DADD_I64 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
|
// RUN: %clangxx -DADD_I64 -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I64
|
||||||
// RUN: %clangxx -DADD_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
|
// RUN: %clangxx -DADD_I128 -fsanitize=unsigned-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-ADD_I128
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -22,7 +22,7 @@ int main() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ADD_I128
|
#ifdef ADD_I128
|
||||||
# ifdef __SIZEOF_INT128__
|
# if defined(__SIZEOF_INT128__) && !defined(_WIN32)
|
||||||
(void)((__uint128_t(1) << 127) + (__uint128_t(1) << 127));
|
(void)((__uint128_t(1) << 127) + (__uint128_t(1) << 127));
|
||||||
# else
|
# else
|
||||||
puts("__int128 not supported");
|
puts("__int128 not supported");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// RUN: %clangxx -DOP=n++ -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck --check-prefix=CHECK-INC %s
|
// RUN: %clangxx -DOP=n++ -fsanitize=unsigned-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck --check-prefix=CHECK-INC %s
|
||||||
// RUN: %clangxx -DOP=++n -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck --check-prefix=CHECK-INC %s
|
// RUN: %clangxx -DOP=++n -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck --check-prefix=CHECK-INC %s
|
||||||
// RUN: %clangxx -DOP=m-- -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
|
// RUN: %clangxx -DOP=m-- -fsanitize=unsigned-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
|
||||||
// RUN: %clangxx -DOP=--m -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
|
// RUN: %clangxx -DOP=--m -fsanitize=unsigned-integer-overflow %s -o %t4 && %run %t4 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// RUN: %clangxx -DSUB_I32 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
|
// RUN: %clangxx -DSUB_I32 -fsanitize=unsigned-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I32
|
||||||
// RUN: %clangxx -DSUB_I64 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
|
// RUN: %clangxx -DSUB_I64 -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I64
|
||||||
// RUN: %clangxx -DSUB_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
|
// RUN: %clangxx -DSUB_I128 -fsanitize=unsigned-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=CHECK-SUB_I128
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -21,7 +21,7 @@ int main() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SUB_I128
|
#ifdef SUB_I128
|
||||||
# ifdef __SIZEOF_INT128__
|
# if defined(__SIZEOF_INT128__) && !defined(_WIN32)
|
||||||
(void)((__uint128_t(1) << 126) - (__uint128_t(1) << 127));
|
(void)((__uint128_t(1) << 126) - (__uint128_t(1) << 127));
|
||||||
# else
|
# else
|
||||||
puts("__int128 not supported\n");
|
puts("__int128 not supported\n");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// RUN: %clangxx -fsanitize=bounds %s -O3 -o %t
|
// RUN: %clangxx -fsanitize=bounds %s -O3 -o %t
|
||||||
// RUN: %run %t 0 0 0
|
// RUN: %run %t 0 0 0
|
||||||
// RUN: %run %t 1 2 3
|
// RUN: %run %t 1 2 3
|
||||||
// RUN: not --crash %run %t 2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK-A-2
|
// RUN: %expect_crash %run %t 2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK-A-2
|
||||||
// RUN: %run %t 0 3 0 2>&1 | FileCheck %s --check-prefix=CHECK-B-3
|
// RUN: %run %t 0 3 0 2>&1 | FileCheck %s --check-prefix=CHECK-B-3
|
||||||
// RUN: %run %t 0 0 4 2>&1 | FileCheck %s --check-prefix=CHECK-C-4
|
// RUN: %run %t 0 0 4 2>&1 | FileCheck %s --check-prefix=CHECK-C-4
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ void overflow() {
|
||||||
int main() {
|
int main() {
|
||||||
// CHECK: Start
|
// CHECK: Start
|
||||||
fprintf(stderr, "Start\n");
|
fprintf(stderr, "Start\n");
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
// CHECK: runtime error
|
// CHECK: runtime error
|
||||||
// CHECK-NOT: runtime error
|
// CHECK-NOT: runtime error
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E" %s -O3 -o %t && %run %t
|
// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E" %s -O3 -o %t && %run %t
|
||||||
// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL
|
// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL
|
||||||
|
|
||||||
|
// FIXME: UBSan fails to add the correct instrumentation code for some reason on
|
||||||
|
// Windows.
|
||||||
|
// XFAIL: win32
|
||||||
|
|
||||||
enum E { a = 1 } e;
|
enum E { a = 1 } e;
|
||||||
#undef E
|
#undef E
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// RUN: %clangxx -fsanitize=return -g %s -O3 -o %t
|
// RUN: %clangxx -fsanitize=return -g %s -O3 -o %t
|
||||||
// RUN: not %run %t 2>&1 | FileCheck %s
|
// RUN: not %run %t 2>&1 | FileCheck %s
|
||||||
// RUN: UBSAN_OPTIONS=print_stacktrace=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%os-STACKTRACE
|
// RUN: env UBSAN_OPTIONS=print_stacktrace=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%os-STACKTRACE
|
||||||
|
|
||||||
// CHECK: missing_return.cpp:[[@LINE+1]]:5: runtime error: execution reached the end of a value-returning function without returning a value
|
// CHECK: missing_return.cpp:[[@LINE+1]]:5: runtime error: execution reached the end of a value-returning function without returning a value
|
||||||
int f() {
|
int f() {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
// RUN: %run %t f1 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
|
// RUN: %run %t f1 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
|
||||||
// RUN: %run %t n1 2>&1 | FileCheck %s --check-prefix=CHECK-NEW
|
// RUN: %run %t n1 2>&1 | FileCheck %s --check-prefix=CHECK-NEW
|
||||||
// RUN: %run %t u1 2>&1 | FileCheck %s --check-prefix=CHECK-UPCAST
|
// RUN: %run %t u1 2>&1 | FileCheck %s --check-prefix=CHECK-UPCAST
|
||||||
// RUN: UBSAN_OPTIONS=print_stacktrace=1 %run %t l1 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD --check-prefix=CHECK-%os-STACK-LOAD
|
// RUN: env UBSAN_OPTIONS=print_stacktrace=1 %run %t l1 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD --check-prefix=CHECK-%os-STACK-LOAD
|
||||||
|
|
||||||
// RUN: %clangxx -fsanitize=alignment -fno-sanitize-recover=alignment %s -O3 -o %t
|
// RUN: %clangxx -fsanitize=alignment -fno-sanitize-recover=alignment %s -O3 -o %t
|
||||||
// RUN: not %run %t w1 2>&1 | FileCheck %s --check-prefix=CHECK-WILD
|
// RUN: not %run %t w1 2>&1 | FileCheck %s --check-prefix=CHECK-WILD
|
||||||
|
@ -38,7 +38,7 @@ int main(int, char **argv) {
|
||||||
|
|
||||||
switch (argv[1][0]) {
|
switch (argv[1][0]) {
|
||||||
case 'l':
|
case 'l':
|
||||||
// CHECK-LOAD: misaligned.cpp:[[@LINE+4]]:12: runtime error: load of misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
|
// CHECK-LOAD: misaligned.cpp:[[@LINE+4]]{{(:12)?}}: runtime error: load of misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
|
||||||
// CHECK-LOAD-NEXT: [[PTR]]: note: pointer points here
|
// CHECK-LOAD-NEXT: [[PTR]]: note: pointer points here
|
||||||
// CHECK-LOAD-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
// CHECK-LOAD-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
||||||
// CHECK-LOAD-NEXT: {{^ \^}}
|
// CHECK-LOAD-NEXT: {{^ \^}}
|
||||||
|
@ -50,7 +50,7 @@ int main(int, char **argv) {
|
||||||
// CHECK-Darwin-STACK-LOAD: {{ }}
|
// CHECK-Darwin-STACK-LOAD: {{ }}
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
// CHECK-STORE: misaligned.cpp:[[@LINE+4]]:5: runtime error: store to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
|
// CHECK-STORE: misaligned.cpp:[[@LINE+4]]{{(:5)?}}: runtime error: store to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
|
||||||
// CHECK-STORE-NEXT: [[PTR]]: note: pointer points here
|
// CHECK-STORE-NEXT: [[PTR]]: note: pointer points here
|
||||||
// CHECK-STORE-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
// CHECK-STORE-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
||||||
// CHECK-STORE-NEXT: {{^ \^}}
|
// CHECK-STORE-NEXT: {{^ \^}}
|
||||||
|
@ -58,7 +58,7 @@ int main(int, char **argv) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
// CHECK-REFERENCE: misaligned.cpp:[[@LINE+4]]:15: runtime error: reference binding to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
|
// CHECK-REFERENCE: misaligned.cpp:[[@LINE+4]]{{(:(5|15))?}}: runtime error: reference binding to misaligned address [[PTR:0x[0-9a-f]*]] for type 'int', which requires 4 byte alignment
|
||||||
// CHECK-REFERENCE-NEXT: [[PTR]]: note: pointer points here
|
// CHECK-REFERENCE-NEXT: [[PTR]]: note: pointer points here
|
||||||
// CHECK-REFERENCE-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
// CHECK-REFERENCE-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
||||||
// CHECK-REFERENCE-NEXT: {{^ \^}}
|
// CHECK-REFERENCE-NEXT: {{^ \^}}
|
||||||
|
@ -66,28 +66,28 @@ int main(int, char **argv) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
// CHECK-MEMBER: misaligned.cpp:[[@LINE+4]]:15: runtime error: member access within misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
|
// CHECK-MEMBER: misaligned.cpp:[[@LINE+4]]{{(:15)?}}: runtime error: member access within misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
|
||||||
// CHECK-MEMBER-NEXT: [[PTR]]: note: pointer points here
|
// CHECK-MEMBER-NEXT: [[PTR]]: note: pointer points here
|
||||||
// CHECK-MEMBER-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
// CHECK-MEMBER-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
||||||
// CHECK-MEMBER-NEXT: {{^ \^}}
|
// CHECK-MEMBER-NEXT: {{^ \^}}
|
||||||
return s->k && 0;
|
return s->k && 0;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
// CHECK-MEMFUN: misaligned.cpp:[[@LINE+4]]:12: runtime error: member call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
|
// CHECK-MEMFUN: misaligned.cpp:[[@LINE+4]]{{(:12)?}}: runtime error: member call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
|
||||||
// CHECK-MEMFUN-NEXT: [[PTR]]: note: pointer points here
|
// CHECK-MEMFUN-NEXT: [[PTR]]: note: pointer points here
|
||||||
// CHECK-MEMFUN-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
// CHECK-MEMFUN-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
||||||
// CHECK-MEMFUN-NEXT: {{^ \^}}
|
// CHECK-MEMFUN-NEXT: {{^ \^}}
|
||||||
return s->f() && 0;
|
return s->f() && 0;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
// CHECK-NEW: misaligned.cpp:[[@LINE+4]]:21: runtime error: constructor call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
|
// CHECK-NEW: misaligned.cpp:[[@LINE+4]]{{(:21)?}}: runtime error: constructor call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
|
||||||
// CHECK-NEW-NEXT: [[PTR]]: note: pointer points here
|
// CHECK-NEW-NEXT: [[PTR]]: note: pointer points here
|
||||||
// CHECK-NEW-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
// CHECK-NEW-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
||||||
// CHECK-NEW-NEXT: {{^ \^}}
|
// CHECK-NEW-NEXT: {{^ \^}}
|
||||||
return (new (s) S)->k && 0;
|
return (new (s) S)->k && 0;
|
||||||
|
|
||||||
case 'u': {
|
case 'u': {
|
||||||
// CHECK-UPCAST: misaligned.cpp:[[@LINE+4]]:17: runtime error: upcast of misaligned address [[PTR:0x[0-9a-f]*]] for type 'T', which requires 4 byte alignment
|
// CHECK-UPCAST: misaligned.cpp:[[@LINE+4]]{{(:17)?}}: runtime error: upcast of misaligned address [[PTR:0x[0-9a-f]*]] for type 'T', which requires 4 byte alignment
|
||||||
// CHECK-UPCAST-NEXT: [[PTR]]: note: pointer points here
|
// CHECK-UPCAST-NEXT: [[PTR]]: note: pointer points here
|
||||||
// CHECK-UPCAST-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
// CHECK-UPCAST-NEXT: {{^ 00 00 00 01 02 03 04 05}}
|
||||||
// CHECK-UPCAST-NEXT: {{^ \^}}
|
// CHECK-UPCAST-NEXT: {{^ \^}}
|
||||||
|
@ -96,7 +96,7 @@ int main(int, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
// CHECK-WILD: misaligned.cpp:[[@LINE+3]]:35: runtime error: member access within misaligned address 0x{{0+}}123 for type 'S', which requires 4 byte alignment
|
// CHECK-WILD: misaligned.cpp:[[@LINE+3]]{{(:35)?}}: runtime error: member access within misaligned address 0x{{0+}}123 for type 'S', which requires 4 byte alignment
|
||||||
// CHECK-WILD-NEXT: 0x{{0+}}123: note: pointer points here
|
// CHECK-WILD-NEXT: 0x{{0+}}123: note: pointer points here
|
||||||
// CHECK-WILD-NEXT: <memory cannot be printed>
|
// CHECK-WILD-NEXT: <memory cannot be printed>
|
||||||
return static_cast<S*>(wild)->k;
|
return static_cast<S*>(wild)->k;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// RUN: %clangxx -fsanitize=null %s -O3 -o %t
|
// RUN: %clangxx -fsanitize=null %s -O3 -o %t
|
||||||
// RUN: %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD
|
// RUN: %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD
|
||||||
// RUN: not --crash %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
|
// RUN: %expect_crash %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
|
||||||
// RUN: %run %t r 2>&1 | FileCheck %s --check-prefix=CHECK-REFERENCE
|
// RUN: %run %t r 2>&1 | FileCheck %s --check-prefix=CHECK-REFERENCE
|
||||||
// RUN: %run %t m 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
|
// RUN: %run %t m 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
|
||||||
// RUN: %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
|
// RUN: %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
|
||||||
|
|
|
@ -51,7 +51,7 @@ config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags
|
||||||
config.suffixes = ['.c', '.cc', '.cpp']
|
config.suffixes = ['.c', '.cc', '.cpp']
|
||||||
|
|
||||||
# Check that the host supports UndefinedBehaviorSanitizer tests
|
# Check that the host supports UndefinedBehaviorSanitizer tests
|
||||||
if config.host_os not in ['Linux', 'Darwin', 'FreeBSD']:
|
if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'Windows']:
|
||||||
config.unsupported = True
|
config.unsupported = True
|
||||||
|
|
||||||
# Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL
|
# Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL
|
||||||
|
|
Loading…
Reference in New Issue