Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,34 @@
// Test dedup_token_length
// RUN: %clangxx -O0 %s -o %t
// RUN: env %tool_options='abort_on_error=0' not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0 --match-full-lines
// RUN: env %tool_options='abort_on_error=0, dedup_token_length=0' not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0 --match-full-lines
// RUN: env %tool_options='abort_on_error=0, dedup_token_length=1' not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --match-full-lines
// RUN: env %tool_options='abort_on_error=0, dedup_token_length=2' not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --match-full-lines
// RUN: env %tool_options='abort_on_error=0, dedup_token_length=3' not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --match-full-lines
// REQUIRES: stable-runtime
volatile int *null = 0;
namespace Xyz {
template<class A, class B> void Abc() {
*null = 0;
}
}
extern "C" void bar() {
Xyz::Abc<int, int>();
}
void FOO() {
bar();
}
int main(int argc, char **argv) {
FOO();
}
// CHECK0-NOT: DEDUP_TOKEN:
// CHECK1: DEDUP_TOKEN: void Xyz::Abc<int, int>()
// CHECK2: DEDUP_TOKEN: void Xyz::Abc<int, int>()--bar
// CHECK3: DEDUP_TOKEN: void Xyz::Abc<int, int>()--bar--FOO()

View File

@@ -0,0 +1,23 @@
// Check that sanitizer prints the faulting instruction bytes on
// dump_instruction_bytes=1
// clang-format off
// RUN: %clangxx %s -o %t
// RUN: %env_tool_opts=dump_instruction_bytes=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-DUMP
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NODUMP
// clang-format on
// REQUIRES: x86-target-arch
int main() {
#if defined(__x86_64__)
asm("movq $0, %rax");
asm("movl $0xcafebabe, 0x0(%rax)");
#elif defined(i386)
asm("movl $0, %eax");
asm("movl $0xcafebabe, 0x0(%eax)");
#endif
// CHECK-DUMP: First 16 instruction bytes at pc: c7 00 be ba fe ca
// CHECK-NODUMP-NOT: First 16 instruction bytes
return 0;
}

View File

@@ -0,0 +1,20 @@
// Check that sanitizer prints registers dump_registers on dump_registers=1
// RUN: %clangxx %s -o %t
// RUN: %env_tool_opts=dump_registers=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NODUMP
// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-DUMP
//
// FIXME: Implement.
// UNSUPPORTED: asan
// UNSUPPORTED: lsan
// UNSUPPORTED: msan
// UNSUPPORTED: tsan
// UNSUPPORTED: ubsan
#include <signal.h>
int main() {
raise(SIGSEGV);
// CHECK-DUMP: Register values
// CHECK-NODUMP-NOT: Register values
return 0;
}

View File

@@ -0,0 +1,29 @@
// Test the handle_sigfpe option.
// RUN: %clangxx %s -o %t
// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s
// RUN: %env_tool_opts=handle_sigfpe=0 not --crash %run %t 2>&1 | FileCheck --check-prefix=CHECK0 %s
// RUN: %env_tool_opts=handle_sigfpe=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s
// FIXME: seems to fail on ARM
// REQUIRES: x86_64-target-arch
#include <assert.h>
#include <stdio.h>
#include <sanitizer/asan_interface.h>
void death() {
fprintf(stderr, "DEATH CALLBACK\n");
}
int main(int argc, char **argv) {
__sanitizer_set_death_callback(death);
volatile int one = 1;
volatile int zero = 0;
volatile int sink;
sink = one / zero;
}
// CHECK0-NOT: Sanitizer:DEADLYSIGNAL
// CHECK1: ERROR: {{.*}}Sanitizer: FPE
// CHECK1: {{#[0-9]+.* main .*fpe\.cc}}:[[@LINE-5]]
// CHECK1: DEATH CALLBACK
// CHECK0-NOT: Sanitizer

View File

@@ -0,0 +1,40 @@
// RUN: %clangxx -O0 -g %s -lutil -o %t && %run %t | FileCheck %s
// REQUIRES: stable-runtime
// XFAIL: android && asan
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#if __linux__
#include <pty.h>
#else
#include <util.h>
#endif
int
main (int argc, char** argv)
{
int master;
int pid = forkpty(&master, NULL, NULL, NULL);
if(pid == -1) {
fprintf(stderr, "forkpty failed\n");
return 1;
} else if (pid > 0) {
char buf[1024];
int res = read(master, buf, sizeof(buf));
write(1, buf, res);
write(master, "password\n", 9);
while ((res = read(master, buf, sizeof(buf))) > 0) write(1, buf, res);
} else {
char *s = getpass("prompt");
assert(strcmp(s, "password") == 0);
write(1, "done\n", 5);
}
return 0;
}
// CHECK: prompt
// CHECK: done

View File

@@ -0,0 +1,9 @@
def getRoot(config):
if not config.parent:
return config
return getRoot(config.parent)
root = getRoot(config)
if root.host_os in ['Windows']:
config.unsupported = True

View File

@@ -0,0 +1,48 @@
// RUN: %clangxx -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// REQUIRES: stable-runtime
// For standalone LSan on x86 we have a problem: compiler spills the address
// of allocated at line 42 memory thus memory block allocated in Leak() function
// ends up to be classified as reachable despite the fact we zero out 'sink' at
// the last line of main function. The problem doesn't reproduce with ASan because
// quarantine prohibits memory block reuse for different allocations.
// XFAIL: lsan-x86
// XFAIL: ubsan
#include <sanitizer/common_interface_defs.h>
#include <stdio.h>
volatile char *zero = 0;
void Death() {
fprintf(stderr, "DEATH CALLBACK EXECUTED\n");
}
// CHECK: DEATH CALLBACK EXECUTED
char global;
volatile char *sink;
__attribute__((noinline))
void MaybeInit(int *uninitialized) {
if (zero)
*uninitialized = 1;
}
__attribute__((noinline))
void Leak() {
sink = new char[100]; // trigger lsan report.
}
int main(int argc, char **argv) {
int uninitialized;
__sanitizer_set_death_callback(Death);
MaybeInit(&uninitialized);
if (uninitialized) // trigger msan report.
global = 77;
sink = new char[100];
delete[] sink;
global = sink[0]; // use-after-free: trigger asan/tsan report.
Leak();
sink = 0;
}

View File

@@ -0,0 +1,34 @@
// Test __sanitizer_set_report_fd:
// RUN: %clangxx -O2 %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
// RUN: not %run %t stdout | FileCheck %s
// RUN: not %run %t %t-out && FileCheck < %t-out %s
// REQUIRES: stable-runtime
// XFAIL: android && asan
#include <sanitizer/common_interface_defs.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
volatile int *null = 0;
int main(int argc, char **argv) {
if (argc == 2) {
if (!strcmp(argv[1], "stdout")) {
__sanitizer_set_report_fd(reinterpret_cast<void*>(1));
} else {
int fd = open(argv[1], O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU);
assert(fd > 0);
__sanitizer_set_report_fd(reinterpret_cast<void*>(fd));
}
}
*null = 0;
}
// CHECK: ERROR: {{.*}} SEGV on unknown address

View File

@@ -0,0 +1,83 @@
// Test the weak hooks.
// RUN: %clangxx %s -o %t
// RUN: %run %t
// Hooks are not implemented for lsan.
// XFAIL: lsan
// XFAIL: ubsan
#include <string.h>
#include <assert.h>
bool seen_memcmp, seen_strncmp, seen_strncasecmp, seen_strcmp, seen_strcasecmp,
seen_strstr, seen_strcasestr, seen_memmem;
extern "C" {
void __sanitizer_weak_hook_memcmp(void *called_pc, const void *s1,
const void *s2, size_t n, int result) {
seen_memcmp = true;
}
void __sanitizer_weak_hook_strncmp(void *called_pc, const char *s1,
const char *s2, size_t n, int result) {
seen_strncmp = true;
}
void __sanitizer_weak_hook_strncasecmp(void *called_pc, const char *s1,
const char *s2, size_t n, int result){
seen_strncasecmp = true;
}
void __sanitizer_weak_hook_strcmp(void *called_pc, const char *s1,
const char *s2, int result){
seen_strcmp = true;
}
void __sanitizer_weak_hook_strcasecmp(void *called_pc, const char *s1,
const char *s2, int result){
seen_strcasecmp = true;
}
void __sanitizer_weak_hook_strstr(void *called_pc, const char *s1,
const char *s2, char *result){
seen_strstr = true;
}
void __sanitizer_weak_hook_strcasestr(void *called_pc, const char *s1,
const char *s2, char *result){
seen_strcasestr = true;
}
void __sanitizer_weak_hook_memmem(void *called_pc, const void *s1, size_t len1,
const void *s2, size_t len2, void *result){
seen_memmem = true;
}
} // extern "C"
char s1[] = "ABCDEF";
char s2[] = "CDE";
static volatile int int_sink;
static volatile void *ptr_sink;
int main() {
assert(sizeof(s2) < sizeof(s1));
int_sink = memcmp(s1, s2, sizeof(s2));
assert(seen_memcmp);
int_sink = strncmp(s1, s2, sizeof(s2));
assert(seen_strncmp);
int_sink = strncasecmp(s1, s2, sizeof(s2));
assert(seen_strncasecmp);
int_sink = strcmp(s1, s2);
assert(seen_strcmp);
int_sink = strcasecmp(s1, s2);
assert(seen_strcasecmp);
ptr_sink = strstr(s1, s2);
assert(seen_strstr);
ptr_sink = strcasestr(s1, s2);
assert(seen_strcasestr);
ptr_sink = memmem(s1, sizeof(s1), s2, sizeof(s2));
assert(seen_memmem);
return 0;
}