aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tsan
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tsan')
-rw-r--r--lib/tsan/benchmarks/func_entry_exit.cpp (renamed from lib/tsan/benchmarks/func_entry_exit.cc)0
-rw-r--r--lib/tsan/benchmarks/mini_bench_local.cpp (renamed from lib/tsan/benchmarks/mini_bench_local.cc)0
-rw-r--r--lib/tsan/benchmarks/mini_bench_shared.cpp (renamed from lib/tsan/benchmarks/mini_bench_shared.cc)0
-rw-r--r--lib/tsan/benchmarks/mop.cpp (renamed from lib/tsan/benchmarks/mop.cc)0
-rw-r--r--lib/tsan/benchmarks/start_many_threads.cpp (renamed from lib/tsan/benchmarks/start_many_threads.cc)0
-rw-r--r--lib/tsan/benchmarks/vts_many_threads_bench.cpp (renamed from lib/tsan/benchmarks/vts_many_threads_bench.cc)0
-rw-r--r--lib/tsan/dd/dd_interceptors.cpp (renamed from lib/tsan/dd/dd_interceptors.cc)2
-rw-r--r--lib/tsan/dd/dd_rtl.cpp (renamed from lib/tsan/dd/dd_rtl.cc)2
-rw-r--r--lib/tsan/go/tsan_go.cpp (renamed from lib/tsan/go/tsan_go.cc)27
-rw-r--r--lib/tsan/rtl/tsan_clock.cpp (renamed from lib/tsan/rtl/tsan_clock.cc)4
-rw-r--r--lib/tsan/rtl/tsan_debugging.cpp (renamed from lib/tsan/rtl/tsan_debugging.cc)2
-rw-r--r--lib/tsan/rtl/tsan_dispatch_defs.h14
-rw-r--r--lib/tsan/rtl/tsan_external.cpp (renamed from lib/tsan/rtl/tsan_external.cc)4
-rw-r--r--lib/tsan/rtl/tsan_fd.cpp (renamed from lib/tsan/rtl/tsan_fd.cc)5
-rw-r--r--lib/tsan/rtl/tsan_flags.cpp (renamed from lib/tsan/rtl/tsan_flags.cc)2
-rw-r--r--lib/tsan/rtl/tsan_ignoreset.cpp (renamed from lib/tsan/rtl/tsan_ignoreset.cc)2
-rw-r--r--lib/tsan/rtl/tsan_interceptors_libdispatch.cpp (renamed from lib/tsan/rtl/tsan_libdispatch.cc)2
-rw-r--r--lib/tsan/rtl/tsan_interceptors_mac.cpp (renamed from lib/tsan/rtl/tsan_interceptors_mac.cc)44
-rw-r--r--lib/tsan/rtl/tsan_interceptors_mach_vm.cpp52
-rw-r--r--lib/tsan/rtl/tsan_interceptors_posix.cpp (renamed from lib/tsan/rtl/tsan_interceptors.cc)47
-rw-r--r--lib/tsan/rtl/tsan_interface.cpp (renamed from lib/tsan/rtl/tsan_interface.cc)4
-rw-r--r--lib/tsan/rtl/tsan_interface.h13
-rw-r--r--lib/tsan/rtl/tsan_interface_ann.cpp (renamed from lib/tsan/rtl/tsan_interface_ann.cc)6
-rw-r--r--lib/tsan/rtl/tsan_interface_atomic.cpp (renamed from lib/tsan/rtl/tsan_interface_atomic.cc)4
-rw-r--r--lib/tsan/rtl/tsan_interface_inl.h10
-rw-r--r--lib/tsan/rtl/tsan_interface_java.cpp (renamed from lib/tsan/rtl/tsan_interface_java.cc)4
-rw-r--r--lib/tsan/rtl/tsan_interface_java.h4
-rw-r--r--lib/tsan/rtl/tsan_malloc_mac.cpp (renamed from lib/tsan/rtl/tsan_malloc_mac.cc)2
-rw-r--r--lib/tsan/rtl/tsan_md5.cpp (renamed from lib/tsan/rtl/tsan_md5.cc)4
-rw-r--r--lib/tsan/rtl/tsan_mman.cpp (renamed from lib/tsan/rtl/tsan_mman.cc)2
-rw-r--r--lib/tsan/rtl/tsan_mman.h5
-rw-r--r--lib/tsan/rtl/tsan_mutex.cpp (renamed from lib/tsan/rtl/tsan_mutex.cc)2
-rw-r--r--lib/tsan/rtl/tsan_mutexset.cpp (renamed from lib/tsan/rtl/tsan_mutexset.cc)2
-rw-r--r--lib/tsan/rtl/tsan_new_delete.cpp (renamed from lib/tsan/rtl/tsan_new_delete.cc)4
-rw-r--r--lib/tsan/rtl/tsan_platform.h2
-rw-r--r--lib/tsan/rtl/tsan_platform_linux.cpp (renamed from lib/tsan/rtl/tsan_platform_linux.cc)2
-rw-r--r--lib/tsan/rtl/tsan_platform_mac.cpp (renamed from lib/tsan/rtl/tsan_platform_mac.cc)2
-rw-r--r--lib/tsan/rtl/tsan_platform_posix.cpp (renamed from lib/tsan/rtl/tsan_platform_posix.cc)11
-rw-r--r--lib/tsan/rtl/tsan_platform_windows.cpp (renamed from lib/tsan/rtl/tsan_platform_windows.cc)2
-rw-r--r--lib/tsan/rtl/tsan_preinit.cpp (renamed from lib/tsan/rtl/tsan_preinit.cc)2
-rw-r--r--lib/tsan/rtl/tsan_report.cpp (renamed from lib/tsan/rtl/tsan_report.cc)4
-rw-r--r--lib/tsan/rtl/tsan_rtl.cpp (renamed from lib/tsan/rtl/tsan_rtl.cc)24
-rw-r--r--lib/tsan/rtl/tsan_rtl.h5
-rw-r--r--lib/tsan/rtl/tsan_rtl_mutex.cpp (renamed from lib/tsan/rtl/tsan_rtl_mutex.cc)2
-rw-r--r--lib/tsan/rtl/tsan_rtl_proc.cpp (renamed from lib/tsan/rtl/tsan_rtl_proc.cc)2
-rw-r--r--lib/tsan/rtl/tsan_rtl_report.cpp (renamed from lib/tsan/rtl/tsan_rtl_report.cc)9
-rw-r--r--lib/tsan/rtl/tsan_rtl_thread.cpp (renamed from lib/tsan/rtl/tsan_rtl_thread.cc)2
-rw-r--r--lib/tsan/rtl/tsan_stack_trace.cpp (renamed from lib/tsan/rtl/tsan_stack_trace.cc)2
-rw-r--r--lib/tsan/rtl/tsan_stat.cpp (renamed from lib/tsan/rtl/tsan_stat.cc)2
-rw-r--r--lib/tsan/rtl/tsan_suppressions.cpp (renamed from lib/tsan/rtl/tsan_suppressions.cc)4
-rw-r--r--lib/tsan/rtl/tsan_symbolize.cpp (renamed from lib/tsan/rtl/tsan_symbolize.cc)2
-rw-r--r--lib/tsan/rtl/tsan_sync.cpp (renamed from lib/tsan/rtl/tsan_sync.cc)2
52 files changed, 242 insertions, 114 deletions
diff --git a/lib/tsan/benchmarks/func_entry_exit.cc b/lib/tsan/benchmarks/func_entry_exit.cpp
index 5e0ba1d6981b..5e0ba1d6981b 100644
--- a/lib/tsan/benchmarks/func_entry_exit.cc
+++ b/lib/tsan/benchmarks/func_entry_exit.cpp
diff --git a/lib/tsan/benchmarks/mini_bench_local.cc b/lib/tsan/benchmarks/mini_bench_local.cpp
index accdcb63878f..accdcb63878f 100644
--- a/lib/tsan/benchmarks/mini_bench_local.cc
+++ b/lib/tsan/benchmarks/mini_bench_local.cpp
diff --git a/lib/tsan/benchmarks/mini_bench_shared.cc b/lib/tsan/benchmarks/mini_bench_shared.cpp
index f9b9f42f78a4..f9b9f42f78a4 100644
--- a/lib/tsan/benchmarks/mini_bench_shared.cc
+++ b/lib/tsan/benchmarks/mini_bench_shared.cpp
diff --git a/lib/tsan/benchmarks/mop.cc b/lib/tsan/benchmarks/mop.cpp
index e87fab856969..e87fab856969 100644
--- a/lib/tsan/benchmarks/mop.cc
+++ b/lib/tsan/benchmarks/mop.cpp
diff --git a/lib/tsan/benchmarks/start_many_threads.cc b/lib/tsan/benchmarks/start_many_threads.cpp
index 1e86fa6c502e..1e86fa6c502e 100644
--- a/lib/tsan/benchmarks/start_many_threads.cc
+++ b/lib/tsan/benchmarks/start_many_threads.cpp
diff --git a/lib/tsan/benchmarks/vts_many_threads_bench.cc b/lib/tsan/benchmarks/vts_many_threads_bench.cpp
index f1056e20c874..f1056e20c874 100644
--- a/lib/tsan/benchmarks/vts_many_threads_bench.cc
+++ b/lib/tsan/benchmarks/vts_many_threads_bench.cpp
diff --git a/lib/tsan/dd/dd_interceptors.cc b/lib/tsan/dd/dd_interceptors.cpp
index 35a72eb36a30..35a0beb19196 100644
--- a/lib/tsan/dd/dd_interceptors.cc
+++ b/lib/tsan/dd/dd_interceptors.cpp
@@ -1,4 +1,4 @@
-//===-- dd_interceptors.cc ------------------------------------------------===//
+//===-- dd_interceptors.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/dd/dd_rtl.cc b/lib/tsan/dd/dd_rtl.cpp
index 08652ba01cdd..2095217586a8 100644
--- a/lib/tsan/dd/dd_rtl.cc
+++ b/lib/tsan/dd/dd_rtl.cpp
@@ -1,4 +1,4 @@
-//===-- dd_rtl.cc ---------------------------------------------------------===//
+//===-- dd_rtl.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/go/tsan_go.cc b/lib/tsan/go/tsan_go.cpp
index dfd1e1da158f..f5998c0c7816 100644
--- a/lib/tsan/go/tsan_go.cc
+++ b/lib/tsan/go/tsan_go.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_go.cc --------------------------------------------------------===//
+//===-- tsan_go.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -54,20 +54,31 @@ struct SymbolizeCodeContext {
};
SymbolizedStack *SymbolizeCode(uptr addr) {
- SymbolizedStack *s = SymbolizedStack::New(addr);
- SymbolizeCodeContext cbctx;
- internal_memset(&cbctx, 0, sizeof(cbctx));
- cbctx.pc = addr;
- go_runtime_cb(CallbackSymbolizeCode, &cbctx);
- if (cbctx.res) {
+ SymbolizedStack *first = SymbolizedStack::New(addr);
+ SymbolizedStack *s = first;
+ for (;;) {
+ SymbolizeCodeContext cbctx;
+ internal_memset(&cbctx, 0, sizeof(cbctx));
+ cbctx.pc = addr;
+ go_runtime_cb(CallbackSymbolizeCode, &cbctx);
+ if (cbctx.res == 0)
+ break;
AddressInfo &info = s->info;
info.module_offset = cbctx.off;
info.function = internal_strdup(cbctx.func ? cbctx.func : "??");
info.file = internal_strdup(cbctx.file ? cbctx.file : "-");
info.line = cbctx.line;
info.column = 0;
+
+ if (cbctx.pc == addr) // outermost (non-inlined) function
+ break;
+ addr = cbctx.pc;
+ // Allocate a stack entry for the parent of the inlined function.
+ SymbolizedStack *s2 = SymbolizedStack::New(addr);
+ s->next = s2;
+ s = s2;
}
- return s;
+ return first;
}
struct SymbolizeDataContext {
diff --git a/lib/tsan/rtl/tsan_clock.cc b/lib/tsan/rtl/tsan_clock.cpp
index 685ca5518009..4b7aa0653da6 100644
--- a/lib/tsan/rtl/tsan_clock.cc
+++ b/lib/tsan/rtl/tsan_clock.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_clock.cc -----------------------------------------------------===//
+//===-- tsan_clock.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -40,7 +40,7 @@
// release(dst);
// }
//
-// Conformance to this model is extensively verified in tsan_clock_test.cc.
+// Conformance to this model is extensively verified in tsan_clock_test.cpp.
// However, the implementation is significantly more complex. The complexity
// allows to implement important classes of use cases in O(1) instead of O(N).
//
diff --git a/lib/tsan/rtl/tsan_debugging.cc b/lib/tsan/rtl/tsan_debugging.cpp
index 8579db12b666..d3d6255090b7 100644
--- a/lib/tsan/rtl/tsan_debugging.cc
+++ b/lib/tsan/rtl/tsan_debugging.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_debugging.cc -------------------------------------------------===//
+//===-- tsan_debugging.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_dispatch_defs.h b/lib/tsan/rtl/tsan_dispatch_defs.h
index 6f1d1f75f600..298297af31eb 100644
--- a/lib/tsan/rtl/tsan_dispatch_defs.h
+++ b/lib/tsan/rtl/tsan_dispatch_defs.h
@@ -31,11 +31,11 @@ typedef void (^dispatch_block_t)(void);
typedef void (^dispatch_io_handler_t)(bool done, dispatch_data_t data,
int error);
-typedef long dispatch_once_t; // NOLINT
+typedef long dispatch_once_t;
typedef __sanitizer::u64 dispatch_time_t;
-typedef int dispatch_fd_t; // NOLINT
-typedef unsigned long dispatch_io_type_t; // NOLINT
-typedef unsigned long dispatch_io_close_flags_t; // NOLINT
+typedef int dispatch_fd_t;
+typedef unsigned long dispatch_io_type_t;
+typedef unsigned long dispatch_io_close_flags_t;
extern "C" {
void *dispatch_get_context(dispatch_object_t object);
@@ -57,10 +57,10 @@ extern const dispatch_block_t _dispatch_data_destructor_munmap;
#endif
// Data types used in dispatch APIs
-typedef unsigned long size_t; // NOLINT
-typedef unsigned long uintptr_t; // NOLINT
+typedef unsigned long size_t;
+typedef unsigned long uintptr_t;
typedef __sanitizer::s64 off_t;
typedef __sanitizer::u16 mode_t;
-typedef long long_t; // NOLINT
+typedef long long_t;
#endif // TSAN_DISPATCH_DEFS_H
diff --git a/lib/tsan/rtl/tsan_external.cc b/lib/tsan/rtl/tsan_external.cpp
index ba8bb71be43b..0faa1ee93a13 100644
--- a/lib/tsan/rtl/tsan_external.cc
+++ b/lib/tsan/rtl/tsan_external.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_external.cc --------------------------------------------------===//
+//===-- tsan_external.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,7 +25,7 @@ static TagData registered_tags[kExternalTagMax] = {
{},
{"Swift variable", "Swift access race"},
};
-static atomic_uint32_t used_tags{kExternalTagFirstUserAvailable}; // NOLINT.
+static atomic_uint32_t used_tags{kExternalTagFirstUserAvailable};
static TagData *GetTagData(uptr tag) {
// Invalid/corrupted tag? Better return NULL and let the caller deal with it.
if (tag >= atomic_load(&used_tags, memory_order_relaxed)) return nullptr;
diff --git a/lib/tsan/rtl/tsan_fd.cc b/lib/tsan/rtl/tsan_fd.cpp
index 5b562ae68d5a..50a6b56916aa 100644
--- a/lib/tsan/rtl/tsan_fd.cc
+++ b/lib/tsan/rtl/tsan_fd.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_fd.cc --------------------------------------------------------===//
+//===-- tsan_fd.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -86,7 +86,8 @@ static FdDesc *fddesc(ThreadState *thr, uptr pc, int fd) {
else
user_free(thr, pc, p, false);
}
- return &((FdDesc*)l1)[fd % kTableSizeL2]; // NOLINT
+ FdDesc *fds = reinterpret_cast<FdDesc *>(l1);
+ return &fds[fd % kTableSizeL2];
}
// pd must be already ref'ed.
diff --git a/lib/tsan/rtl/tsan_flags.cc b/lib/tsan/rtl/tsan_flags.cpp
index a5abb183a753..44bf325cd35b 100644
--- a/lib/tsan/rtl/tsan_flags.cc
+++ b/lib/tsan/rtl/tsan_flags.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_flags.cc -----------------------------------------------------===//
+//===-- tsan_flags.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_ignoreset.cc b/lib/tsan/rtl/tsan_ignoreset.cpp
index b2f657939cce..f6e41f668618 100644
--- a/lib/tsan/rtl/tsan_ignoreset.cc
+++ b/lib/tsan/rtl/tsan_ignoreset.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_ignoreset.cc -------------------------------------------------===//
+//===-- tsan_ignoreset.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_libdispatch.cc b/lib/tsan/rtl/tsan_interceptors_libdispatch.cpp
index 48ac6a2824a8..5dacd3256abc 100644
--- a/lib/tsan/rtl/tsan_libdispatch.cc
+++ b/lib/tsan/rtl/tsan_interceptors_libdispatch.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_libdispatch.cc -----------------------------------------------===//
+//===-- tsan_interceptors_libdispatch.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_interceptors_mac.cc b/lib/tsan/rtl/tsan_interceptors_mac.cpp
index 99c6df9dfde7..aa29536d8616 100644
--- a/lib/tsan/rtl/tsan_interceptors_mac.cc
+++ b/lib/tsan/rtl/tsan_interceptors_mac.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_interceptors_mac.cc ------------------------------------------===//
+//===-- tsan_interceptors_mac.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -23,13 +23,14 @@
#include <errno.h>
#include <libkern/OSAtomic.h>
#include <objc/objc-sync.h>
+#include <os/lock.h>
#include <sys/ucontext.h>
#if defined(__has_include) && __has_include(<xpc/xpc.h>)
#include <xpc/xpc.h>
#endif // #if defined(__has_include) && __has_include(<xpc/xpc.h>)
-typedef long long_t; // NOLINT
+typedef long long_t;
extern "C" {
int getcontext(ucontext_t *ucp) __attribute__((returns_twice));
@@ -246,6 +247,45 @@ TSAN_INTERCEPTOR(void, os_lock_unlock, void *lock) {
REAL(os_lock_unlock)(lock);
}
+TSAN_INTERCEPTOR(void, os_unfair_lock_lock, os_unfair_lock_t lock) {
+ if (!cur_thread()->is_inited || cur_thread()->is_dead) {
+ return REAL(os_unfair_lock_lock)(lock);
+ }
+ SCOPED_TSAN_INTERCEPTOR(os_unfair_lock_lock, lock);
+ REAL(os_unfair_lock_lock)(lock);
+ Acquire(thr, pc, (uptr)lock);
+}
+
+TSAN_INTERCEPTOR(void, os_unfair_lock_lock_with_options, os_unfair_lock_t lock,
+ u32 options) {
+ if (!cur_thread()->is_inited || cur_thread()->is_dead) {
+ return REAL(os_unfair_lock_lock_with_options)(lock, options);
+ }
+ SCOPED_TSAN_INTERCEPTOR(os_unfair_lock_lock_with_options, lock, options);
+ REAL(os_unfair_lock_lock_with_options)(lock, options);
+ Acquire(thr, pc, (uptr)lock);
+}
+
+TSAN_INTERCEPTOR(bool, os_unfair_lock_trylock, os_unfair_lock_t lock) {
+ if (!cur_thread()->is_inited || cur_thread()->is_dead) {
+ return REAL(os_unfair_lock_trylock)(lock);
+ }
+ SCOPED_TSAN_INTERCEPTOR(os_unfair_lock_trylock, lock);
+ bool result = REAL(os_unfair_lock_trylock)(lock);
+ if (result)
+ Acquire(thr, pc, (uptr)lock);
+ return result;
+}
+
+TSAN_INTERCEPTOR(void, os_unfair_lock_unlock, os_unfair_lock_t lock) {
+ if (!cur_thread()->is_inited || cur_thread()->is_dead) {
+ return REAL(os_unfair_lock_unlock)(lock);
+ }
+ SCOPED_TSAN_INTERCEPTOR(os_unfair_lock_unlock, lock);
+ Release(thr, pc, (uptr)lock);
+ REAL(os_unfair_lock_unlock)(lock);
+}
+
#if defined(__has_include) && __has_include(<xpc/xpc.h>)
TSAN_INTERCEPTOR(void, xpc_connection_set_event_handler,
diff --git a/lib/tsan/rtl/tsan_interceptors_mach_vm.cpp b/lib/tsan/rtl/tsan_interceptors_mach_vm.cpp
new file mode 100644
index 000000000000..cd318f8af93f
--- /dev/null
+++ b/lib/tsan/rtl/tsan_interceptors_mach_vm.cpp
@@ -0,0 +1,52 @@
+//===-- tsan_interceptors_mach_vm.cpp -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of ThreadSanitizer (TSan), a race detector.
+//
+// Interceptors for mach_vm_* user space memory routines on Darwin.
+//===----------------------------------------------------------------------===//
+
+#include "interception/interception.h"
+#include "tsan_interceptors.h"
+#include "tsan_platform.h"
+
+#include <mach/mach.h>
+
+namespace __tsan {
+
+static bool intersects_with_shadow(mach_vm_address_t *address,
+ mach_vm_size_t size, int flags) {
+ // VM_FLAGS_FIXED is 0x0, so we have to test for VM_FLAGS_ANYWHERE.
+ if (flags & VM_FLAGS_ANYWHERE) return false;
+ uptr ptr = *address;
+ return !IsAppMem(ptr) || !IsAppMem(ptr + size - 1);
+}
+
+TSAN_INTERCEPTOR(kern_return_t, mach_vm_allocate, vm_map_t target,
+ mach_vm_address_t *address, mach_vm_size_t size, int flags) {
+ SCOPED_TSAN_INTERCEPTOR(mach_vm_allocate, target, address, size, flags);
+ if (target != mach_task_self())
+ return REAL(mach_vm_allocate)(target, address, size, flags);
+ if (intersects_with_shadow(address, size, flags))
+ return KERN_NO_SPACE;
+ kern_return_t res = REAL(mach_vm_allocate)(target, address, size, flags);
+ if (res == KERN_SUCCESS)
+ MemoryRangeImitateWriteOrResetRange(thr, pc, *address, size);
+ return res;
+}
+
+TSAN_INTERCEPTOR(kern_return_t, mach_vm_deallocate, vm_map_t target,
+ mach_vm_address_t address, mach_vm_size_t size) {
+ SCOPED_TSAN_INTERCEPTOR(mach_vm_deallocate, target, address, size);
+ if (target != mach_task_self())
+ return REAL(mach_vm_deallocate)(target, address, size);
+ UnmapShadow(thr, address, size);
+ return REAL(mach_vm_deallocate)(target, address, size);
+}
+
+} // namespace __tsan
diff --git a/lib/tsan/rtl/tsan_interceptors.cc b/lib/tsan/rtl/tsan_interceptors_posix.cpp
index 9a184c797985..8aea1e4ec051 100644
--- a/lib/tsan/rtl/tsan_interceptors.cc
+++ b/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_interceptors.cc ----------------------------------------------===//
+//===-- tsan_interceptors_posix.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -31,8 +31,7 @@
#include "tsan_mman.h"
#include "tsan_fd.h"
-
-using namespace __tsan; // NOLINT
+using namespace __tsan;
#if SANITIZER_FREEBSD || SANITIZER_MAC
#define stdout __stdoutp
@@ -41,9 +40,10 @@ using namespace __tsan; // NOLINT
#if SANITIZER_NETBSD
#define dirfd(dirp) (*(int *)(dirp))
-#define fileno_unlocked(fp) \
- (((__sanitizer_FILE*)fp)->_file == -1 ? -1 : \
- (int)(unsigned short)(((__sanitizer_FILE*)fp)->_file)) // NOLINT
+#define fileno_unlocked(fp) \
+ (((__sanitizer_FILE *)fp)->_file == -1 \
+ ? -1 \
+ : (int)(unsigned short)(((__sanitizer_FILE *)fp)->_file))
#define stdout ((__sanitizer_FILE*)&__sF[1])
#define stderr ((__sanitizer_FILE*)&__sF[2])
@@ -114,6 +114,7 @@ const int PTHREAD_MUTEX_RECURSIVE_NP = 2;
const int EPOLL_CTL_ADD = 1;
#endif
const int SIGILL = 4;
+const int SIGTRAP = 5;
const int SIGABRT = 6;
const int SIGFPE = 8;
const int SIGSEGV = 11;
@@ -133,7 +134,7 @@ const int PTHREAD_BARRIER_SERIAL_THREAD = 1234567;
const int PTHREAD_BARRIER_SERIAL_THREAD = -1;
#endif
const int MAP_FIXED = 0x10;
-typedef long long_t; // NOLINT
+typedef long long_t;
// From /usr/include/unistd.h
# define F_ULOCK 0 /* Unlock a previously locked region. */
@@ -723,12 +724,12 @@ TSAN_INTERCEPTOR(uptr, malloc_usable_size, void *p) {
}
#endif
-TSAN_INTERCEPTOR(char*, strcpy, char *dst, const char *src) { // NOLINT
- SCOPED_TSAN_INTERCEPTOR(strcpy, dst, src); // NOLINT
+TSAN_INTERCEPTOR(char *, strcpy, char *dst, const char *src) {
+ SCOPED_TSAN_INTERCEPTOR(strcpy, dst, src);
uptr srclen = internal_strlen(src);
MemoryAccessRange(thr, pc, (uptr)dst, srclen + 1, true);
MemoryAccessRange(thr, pc, (uptr)src, srclen + 1, false);
- return REAL(strcpy)(dst, src); // NOLINT
+ return REAL(strcpy)(dst, src);
}
TSAN_INTERCEPTOR(char*, strncpy, char *dst, char *src, uptr n) {
@@ -745,6 +746,8 @@ TSAN_INTERCEPTOR(char*, strdup, const char *str) {
return REAL(strdup)(str);
}
+// Zero out addr if it points into shadow memory and was provided as a hint
+// only, i.e., MAP_FIXED is not set.
static bool fix_mmap_addr(void **addr, long_t sz, int flags) {
if (*addr) {
if (!IsAppMem((uptr)*addr) || !IsAppMem((uptr)*addr + sz - 1)) {
@@ -767,22 +770,14 @@ static void *mmap_interceptor(ThreadState *thr, uptr pc, Mmap real_mmap,
void *res = real_mmap(addr, sz, prot, flags, fd, off);
if (res != MAP_FAILED) {
if (fd > 0) FdAccess(thr, pc, fd);
- if (thr->ignore_reads_and_writes == 0)
- MemoryRangeImitateWrite(thr, pc, (uptr)res, sz);
- else
- MemoryResetRange(thr, pc, (uptr)res, sz);
+ MemoryRangeImitateWriteOrResetRange(thr, pc, (uptr)res, sz);
}
return res;
}
TSAN_INTERCEPTOR(int, munmap, void *addr, long_t sz) {
SCOPED_TSAN_INTERCEPTOR(munmap, addr, sz);
- if (sz != 0) {
- // If sz == 0, munmap will return EINVAL and don't unmap any memory.
- DontNeedShadowFor((uptr)addr, sz);
- ScopedGlobalProcessor sgp;
- ctx->metamap.ResetRange(thr->proc(), (uptr)addr, (uptr)sz);
- }
+ UnmapShadow(thr, (uptr)addr, sz);
int res = REAL(munmap)(addr, sz);
return res;
}
@@ -1157,7 +1152,7 @@ static int cond_wait(ThreadState *thr, uptr pc, ScopedInterceptor *si,
CondMutexUnlockCtx arg = {si, thr, pc, m};
int res = 0;
// This ensures that we handle mutex lock even in case of pthread_cancel.
- // See test/tsan/cond_cancel.cc.
+ // See test/tsan/cond_cancel.cpp.
{
// Enable signal delivery while the thread is blocked.
BlockingCall bc(thr);
@@ -1968,10 +1963,10 @@ void ProcessPendingSignals(ThreadState *thr) {
} // namespace __tsan
static bool is_sync_signal(ThreadSignalContext *sctx, int sig) {
- return sig == SIGSEGV || sig == SIGBUS || sig == SIGILL ||
- sig == SIGABRT || sig == SIGFPE || sig == SIGPIPE || sig == SIGSYS ||
- // If we are sending signal to ourselves, we must process it now.
- (sctx && sig == sctx->int_signal_send);
+ return sig == SIGSEGV || sig == SIGBUS || sig == SIGILL || sig == SIGTRAP ||
+ sig == SIGABRT || sig == SIGFPE || sig == SIGPIPE || sig == SIGSYS ||
+ // If we are sending signal to ourselves, we must process it now.
+ (sctx && sig == sctx->int_signal_send);
}
void ALWAYS_INLINE rtl_generic_sighandler(bool sigact, int sig,
@@ -2666,7 +2661,7 @@ void InitializeInterceptors() {
TSAN_MAYBE_INTERCEPT_PVALLOC;
TSAN_INTERCEPT(posix_memalign);
- TSAN_INTERCEPT(strcpy); // NOLINT
+ TSAN_INTERCEPT(strcpy);
TSAN_INTERCEPT(strncpy);
TSAN_INTERCEPT(strdup);
diff --git a/lib/tsan/rtl/tsan_interface.cc b/lib/tsan/rtl/tsan_interface.cpp
index 508aadb08f62..2b3a0889b70a 100644
--- a/lib/tsan/rtl/tsan_interface.cc
+++ b/lib/tsan/rtl/tsan_interface.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_interface.cc -------------------------------------------------===//
+//===-- tsan_interface.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,7 +17,7 @@
#define CALLERPC ((uptr)__builtin_return_address(0))
-using namespace __tsan; // NOLINT
+using namespace __tsan;
typedef u16 uint16_t;
typedef u32 uint32_t;
diff --git a/lib/tsan/rtl/tsan_interface.h b/lib/tsan/rtl/tsan_interface.h
index fac57809aa24..6d7286ca5b8a 100644
--- a/lib/tsan/rtl/tsan_interface.h
+++ b/lib/tsan/rtl/tsan_interface.h
@@ -90,9 +90,14 @@ SANITIZER_INTERFACE_ATTRIBUTE
void __tsan_external_write(void *addr, void *caller_pc, void *tag);
SANITIZER_INTERFACE_ATTRIBUTE
-void __tsan_read_range(void *addr, unsigned long size); // NOLINT
+void __tsan_read_range(void *addr, unsigned long size);
SANITIZER_INTERFACE_ATTRIBUTE
-void __tsan_write_range(void *addr, unsigned long size); // NOLINT
+void __tsan_write_range(void *addr, unsigned long size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void __tsan_read_range_pc(void *addr, unsigned long size, void *pc); // NOLINT
+SANITIZER_INTERFACE_ATTRIBUTE
+void __tsan_write_range_pc(void *addr, unsigned long size, void *pc); // NOLINT
// User may provide function that would be called right when TSan detects
// an error. The argument 'report' is an opaque pointer that can be used to
@@ -187,9 +192,9 @@ namespace __tsan {
// These should match declarations from public tsan_interface_atomic.h header.
typedef unsigned char a8;
-typedef unsigned short a16; // NOLINT
+typedef unsigned short a16;
typedef unsigned int a32;
-typedef unsigned long long a64; // NOLINT
+typedef unsigned long long a64;
#if !SANITIZER_GO && (defined(__SIZEOF_INT128__) \
|| (__clang_major__ * 100 + __clang_minor__ >= 302)) && !defined(__mips64)
__extension__ typedef __int128 a128;
diff --git a/lib/tsan/rtl/tsan_interface_ann.cc b/lib/tsan/rtl/tsan_interface_ann.cpp
index e141ddbb751a..99516d94bba3 100644
--- a/lib/tsan/rtl/tsan_interface_ann.cc
+++ b/lib/tsan/rtl/tsan_interface_ann.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_interface_ann.cc ---------------------------------------------===//
+//===-- tsan_interface_ann.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -24,7 +24,7 @@
#define CALLERPC ((uptr)__builtin_return_address(0))
-using namespace __tsan; // NOLINT
+using namespace __tsan;
namespace __tsan {
@@ -220,7 +220,7 @@ static void ReportMissedExpectedRace(ExpectRace *race) {
}
} // namespace __tsan
-using namespace __tsan; // NOLINT
+using namespace __tsan;
extern "C" {
void INTERFACE_ATTRIBUTE AnnotateHappensBefore(char *f, int l, uptr addr) {
diff --git a/lib/tsan/rtl/tsan_interface_atomic.cc b/lib/tsan/rtl/tsan_interface_atomic.cpp
index a6b7b0f656d3..3f459aff532c 100644
--- a/lib/tsan/rtl/tsan_interface_atomic.cc
+++ b/lib/tsan/rtl/tsan_interface_atomic.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_interface_atomic.cc ------------------------------------------===//
+//===-- tsan_interface_atomic.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,7 +25,7 @@
#include "tsan_interface.h"
#include "tsan_rtl.h"
-using namespace __tsan; // NOLINT
+using namespace __tsan;
#if !SANITIZER_GO && __TSAN_HAS_INT128
// Protects emulation of 128-bit atomic operations.
diff --git a/lib/tsan/rtl/tsan_interface_inl.h b/lib/tsan/rtl/tsan_interface_inl.h
index bf4a1658625c..f955ddf99247 100644
--- a/lib/tsan/rtl/tsan_interface_inl.h
+++ b/lib/tsan/rtl/tsan_interface_inl.h
@@ -15,7 +15,7 @@
#define CALLERPC ((uptr)__builtin_return_address(0))
-using namespace __tsan; // NOLINT
+using namespace __tsan;
void __tsan_read1(void *addr) {
MemoryRead(cur_thread(), CALLERPC, (uptr)addr, kSizeLog1);
@@ -122,3 +122,11 @@ void __tsan_read_range(void *addr, uptr size) {
void __tsan_write_range(void *addr, uptr size) {
MemoryAccessRange(cur_thread(), CALLERPC, (uptr)addr, size, true);
}
+
+void __tsan_read_range_pc(void *addr, uptr size, void *pc) {
+ MemoryAccessRange(cur_thread(), (uptr)pc, (uptr)addr, size, false);
+}
+
+void __tsan_write_range_pc(void *addr, uptr size, void *pc) {
+ MemoryAccessRange(cur_thread(), (uptr)pc, (uptr)addr, size, true);
+}
diff --git a/lib/tsan/rtl/tsan_interface_java.cc b/lib/tsan/rtl/tsan_interface_java.cpp
index 9f227f09589e..081c6ff1022e 100644
--- a/lib/tsan/rtl/tsan_interface_java.cc
+++ b/lib/tsan/rtl/tsan_interface_java.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_interface_java.cc --------------------------------------------===//
+//===-- tsan_interface_java.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -19,7 +19,7 @@
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "sanitizer_common/sanitizer_procmaps.h"
-using namespace __tsan; // NOLINT
+using namespace __tsan;
const jptr kHeapAlignment = 8;
diff --git a/lib/tsan/rtl/tsan_interface_java.h b/lib/tsan/rtl/tsan_interface_java.h
index 5ad16e959093..51b445251e09 100644
--- a/lib/tsan/rtl/tsan_interface_java.h
+++ b/lib/tsan/rtl/tsan_interface_java.h
@@ -18,7 +18,7 @@
// For volatile memory accesses and atomic operations JVM is intended to use
// standard atomics API: __tsan_atomicN_load/store/etc.
//
-// For usage examples see lit_tests/java_*.cc
+// For usage examples see lit_tests/java_*.cpp
//===----------------------------------------------------------------------===//
#ifndef TSAN_INTERFACE_JAVA_H
#define TSAN_INTERFACE_JAVA_H
@@ -31,7 +31,7 @@
extern "C" {
#endif
-typedef unsigned long jptr; // NOLINT
+typedef unsigned long jptr;
// Must be called before any other callback from Java.
void __tsan_java_init(jptr heap_begin, jptr heap_size) INTERFACE_ATTRIBUTE;
diff --git a/lib/tsan/rtl/tsan_malloc_mac.cc b/lib/tsan/rtl/tsan_malloc_mac.cpp
index 0b874aecb99c..0e861bf1f962 100644
--- a/lib/tsan/rtl/tsan_malloc_mac.cc
+++ b/lib/tsan/rtl/tsan_malloc_mac.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_malloc_mac.cc ------------------------------------------------===//
+//===-- tsan_malloc_mac.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_md5.cc b/lib/tsan/rtl/tsan_md5.cpp
index bfe0c17bae75..72857b773fed 100644
--- a/lib/tsan/rtl/tsan_md5.cc
+++ b/lib/tsan/rtl/tsan_md5.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_md5.cc -------------------------------------------------------===//
+//===-- tsan_md5.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -29,7 +29,7 @@ namespace __tsan {
SET(n)
typedef unsigned int MD5_u32plus;
-typedef unsigned long ulong_t; // NOLINT
+typedef unsigned long ulong_t;
typedef struct {
MD5_u32plus lo, hi;
diff --git a/lib/tsan/rtl/tsan_mman.cc b/lib/tsan/rtl/tsan_mman.cpp
index f4a95d870cab..1b2c0549d399 100644
--- a/lib/tsan/rtl/tsan_mman.cc
+++ b/lib/tsan/rtl/tsan_mman.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_mman.cc ------------------------------------------------------===//
+//===-- tsan_mman.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_mman.h b/lib/tsan/rtl/tsan_mman.h
index 467aabdf2b9d..a5280d4472c9 100644
--- a/lib/tsan/rtl/tsan_mman.h
+++ b/lib/tsan/rtl/tsan_mman.h
@@ -79,11 +79,10 @@ enum MBlockType {
void *internal_alloc(MBlockType typ, uptr sz);
void internal_free(void *p);
-template<typename T>
-void DestroyAndFree(T *&p) {
+template <typename T>
+void DestroyAndFree(T *p) {
p->~T();
internal_free(p);
- p = 0;
}
} // namespace __tsan
diff --git a/lib/tsan/rtl/tsan_mutex.cc b/lib/tsan/rtl/tsan_mutex.cpp
index bb7531325aed..7a0918f2a2c0 100644
--- a/lib/tsan/rtl/tsan_mutex.cc
+++ b/lib/tsan/rtl/tsan_mutex.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_mutex.cc -----------------------------------------------------===//
+//===-- tsan_mutex.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_mutexset.cc b/lib/tsan/rtl/tsan_mutexset.cpp
index 02e5f9da6080..813fa3bca936 100644
--- a/lib/tsan/rtl/tsan_mutexset.cc
+++ b/lib/tsan/rtl/tsan_mutexset.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_mutexset.cc --------------------------------------------------===//
+//===-- tsan_mutexset.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_new_delete.cc b/lib/tsan/rtl/tsan_new_delete.cpp
index 4cbdf703ad28..fc44a5221b5b 100644
--- a/lib/tsan/rtl/tsan_new_delete.cc
+++ b/lib/tsan/rtl/tsan_new_delete.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_new_delete.cc ----------------------------------------------===//
+//===-- tsan_new_delete.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,7 +17,7 @@
#include "tsan_interceptors.h"
#include "tsan_rtl.h"
-using namespace __tsan; // NOLINT
+using namespace __tsan;
namespace std {
struct nothrow_t {};
diff --git a/lib/tsan/rtl/tsan_platform.h b/lib/tsan/rtl/tsan_platform.h
index 0d106c4147c8..63eb14fcd340 100644
--- a/lib/tsan/rtl/tsan_platform.h
+++ b/lib/tsan/rtl/tsan_platform.h
@@ -457,6 +457,8 @@ struct Mapping47 {
static const uptr kAppMemEnd = 0x00e000000000ull;
};
+#define TSAN_RUNTIME_VMA 1
+
#elif SANITIZER_GO && defined(__aarch64__)
/* Go on linux/aarch64 (48-bit VMA)
diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cpp
index ec8606f65d5c..33fa586ca1b0 100644
--- a/lib/tsan/rtl/tsan_platform_linux.cc
+++ b/lib/tsan/rtl/tsan_platform_linux.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_platform_linux.cc --------------------------------------------===//
+//===-- tsan_platform_linux.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_platform_mac.cc b/lib/tsan/rtl/tsan_platform_mac.cpp
index 0c2d2aa9338e..326ca8532e52 100644
--- a/lib/tsan/rtl/tsan_platform_mac.cc
+++ b/lib/tsan/rtl/tsan_platform_mac.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_platform_mac.cc ----------------------------------------------===//
+//===-- tsan_platform_mac.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_platform_posix.cc b/lib/tsan/rtl/tsan_platform_posix.cpp
index 3bd0f1bd48d8..1a0faee0252e 100644
--- a/lib/tsan/rtl/tsan_platform_posix.cc
+++ b/lib/tsan/rtl/tsan_platform_posix.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_platform_posix.cc --------------------------------------------===//
+//===-- tsan_platform_posix.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -30,14 +30,7 @@ static const char kShadowMemoryMappingHint[] =
"TSAN_OPTIONS=%s=0\n";
static void NoHugePagesInShadow(uptr addr, uptr size) {
- if (common_flags()->no_huge_pages_for_shadow)
- if (!NoHugePagesInRegion(addr, size)) {
- Printf(kShadowMemoryMappingWarning, SanitizerToolName, addr, addr + size,
- "MADV_NOHUGEPAGE", errno);
- Printf(kShadowMemoryMappingHint, "MADV_NOHUGEPAGE",
- "no_huge_pages_for_shadow");
- Die();
- }
+ SetShadowRegionHugePageMode(addr, size);
}
static void DontDumpShadow(uptr addr, uptr size) {
diff --git a/lib/tsan/rtl/tsan_platform_windows.cc b/lib/tsan/rtl/tsan_platform_windows.cpp
index 037297559ee0..19437879a41c 100644
--- a/lib/tsan/rtl/tsan_platform_windows.cc
+++ b/lib/tsan/rtl/tsan_platform_windows.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_platform_windows.cc ------------------------------------------===//
+//===-- tsan_platform_windows.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_preinit.cc b/lib/tsan/rtl/tsan_preinit.cpp
index 052b353091d1..205bdbf93b20 100644
--- a/lib/tsan/rtl/tsan_preinit.cc
+++ b/lib/tsan/rtl/tsan_preinit.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_preinit.cc ---------------------------------------------------===//
+//===-- tsan_preinit.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_report.cc b/lib/tsan/rtl/tsan_report.cpp
index ae669024a879..368f1ca8adf2 100644
--- a/lib/tsan/rtl/tsan_report.cc
+++ b/lib/tsan/rtl/tsan_report.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_report.cc ----------------------------------------------------===//
+//===-- tsan_report.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -298,7 +298,7 @@ static bool FrameIsInternal(const SymbolizedStack *frame) {
const char *file = frame->info.file;
const char *module = frame->info.module;
if (file != 0 &&
- (internal_strstr(file, "tsan_interceptors.cc") ||
+ (internal_strstr(file, "tsan_interceptors_posix.cpp") ||
internal_strstr(file, "sanitizer_common_interceptors.inc") ||
internal_strstr(file, "tsan_interface_")))
return true;
diff --git a/lib/tsan/rtl/tsan_rtl.cc b/lib/tsan/rtl/tsan_rtl.cpp
index 8a2704ff0631..3f3c0cce119c 100644
--- a/lib/tsan/rtl/tsan_rtl.cc
+++ b/lib/tsan/rtl/tsan_rtl.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_rtl.cc -------------------------------------------------------===//
+//===-- tsan_rtl.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -149,6 +149,7 @@ static void BackgroundThread(void *arg) {
// We don't use ScopedIgnoreInterceptors, because we want ignores to be
// enabled even when the thread function exits (e.g. during pthread thread
// shutdown code).
+ cur_thread_init();
cur_thread()->ignore_interceptors++;
const u64 kMs2Ns = 1000 * 1000;
@@ -238,6 +239,15 @@ void DontNeedShadowFor(uptr addr, uptr size) {
ReleaseMemoryPagesToOS(MemToShadow(addr), MemToShadow(addr + size));
}
+#if !SANITIZER_GO
+void UnmapShadow(ThreadState *thr, uptr addr, uptr size) {
+ if (size == 0) return;
+ DontNeedShadowFor(addr, size);
+ ScopedGlobalProcessor sgp;
+ ctx->metamap.ResetRange(thr->proc(), addr, size);
+}
+#endif
+
void MapShadow(uptr addr, uptr size) {
// Global data is not 64K aligned, but there are no adjacent mappings,
// so we can get away with unaligned mapping.
@@ -328,7 +338,7 @@ static void CheckShadowMapping() {
#if !SANITIZER_GO
static void OnStackUnwind(const SignalContext &sig, const void *,
BufferedStackTrace *stack) {
- stack->Unwind(sig.pc, sig.bp, sig.context,
+ stack->Unwind(StackTrace::GetNextInstructionPc(sig.pc), sig.bp, sig.context,
common_flags()->fast_unwind_on_fatal);
}
@@ -869,7 +879,7 @@ void MemoryAccess(ThreadState *thr, uptr pc, uptr addr,
shadow_mem, cur);
}
-// Called by MemoryAccessRange in tsan_rtl_thread.cc
+// Called by MemoryAccessRange in tsan_rtl_thread.cpp
ALWAYS_INLINE USED
void MemoryAccessImpl(ThreadState *thr, uptr addr,
int kAccessSizeLog, bool kAccessIsWrite, bool kIsAtomic,
@@ -986,6 +996,14 @@ void MemoryRangeImitateWrite(ThreadState *thr, uptr pc, uptr addr, uptr size) {
MemoryRangeSet(thr, pc, addr, size, s.raw());
}
+void MemoryRangeImitateWriteOrResetRange(ThreadState *thr, uptr pc, uptr addr,
+ uptr size) {
+ if (thr->ignore_reads_and_writes == 0)
+ MemoryRangeImitateWrite(thr, pc, addr, size);
+ else
+ MemoryResetRange(thr, pc, addr, size);
+}
+
ALWAYS_INLINE USED
void FuncEntry(ThreadState *thr, uptr pc) {
StatInc(thr, StatFuncEnter);
diff --git a/lib/tsan/rtl/tsan_rtl.h b/lib/tsan/rtl/tsan_rtl.h
index 3a8231bda9a9..c38fc43a9f84 100644
--- a/lib/tsan/rtl/tsan_rtl.h
+++ b/lib/tsan/rtl/tsan_rtl.h
@@ -238,7 +238,7 @@ class Shadow : public FastState {
unsigned kS2AccessSize) {
bool res = false;
u64 diff = s1.addr0() - s2.addr0();
- if ((s64)diff < 0) { // s1.addr0 < s2.addr0 // NOLINT
+ if ((s64)diff < 0) { // s1.addr0 < s2.addr0
// if (s1.addr0() + size1) > s2.addr0()) return true;
if (s1.size() > -diff)
res = true;
@@ -680,6 +680,7 @@ void ALWAYS_INLINE StatSet(ThreadState *thr, StatType typ, u64 n) {
void MapShadow(uptr addr, uptr size);
void MapThreadTrace(uptr addr, uptr size, const char *name);
void DontNeedShadowFor(uptr addr, uptr size);
+void UnmapShadow(ThreadState *thr, uptr addr, uptr size);
void InitializeShadowMemory();
void InitializeInterceptors();
void InitializeLibIgnore();
@@ -759,6 +760,8 @@ void ALWAYS_INLINE MemoryWriteAtomic(ThreadState *thr, uptr pc,
void MemoryResetRange(ThreadState *thr, uptr pc, uptr addr, uptr size);
void MemoryRangeFreed(ThreadState *thr, uptr pc, uptr addr, uptr size);
void MemoryRangeImitateWrite(ThreadState *thr, uptr pc, uptr addr, uptr size);
+void MemoryRangeImitateWriteOrResetRange(ThreadState *thr, uptr pc, uptr addr,
+ uptr size);
void ThreadIgnoreBegin(ThreadState *thr, uptr pc, bool save_stack = true);
void ThreadIgnoreEnd(ThreadState *thr, uptr pc);
diff --git a/lib/tsan/rtl/tsan_rtl_mutex.cc b/lib/tsan/rtl/tsan_rtl_mutex.cpp
index 941e70f98872..ce6e7cb2c4ef 100644
--- a/lib/tsan/rtl/tsan_rtl_mutex.cc
+++ b/lib/tsan/rtl/tsan_rtl_mutex.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_rtl_mutex.cc -------------------------------------------------===//
+//===-- tsan_rtl_mutex.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_rtl_proc.cc b/lib/tsan/rtl/tsan_rtl_proc.cpp
index 94bbed25b8f5..def61cca14d5 100644
--- a/lib/tsan/rtl/tsan_rtl_proc.cc
+++ b/lib/tsan/rtl/tsan_rtl_proc.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_rtl_proc.cc ------------------------------------------------===//
+//===-- tsan_rtl_proc.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_rtl_report.cc b/lib/tsan/rtl/tsan_rtl_report.cpp
index 220a425a2c5b..949beac1c551 100644
--- a/lib/tsan/rtl/tsan_rtl_report.cc
+++ b/lib/tsan/rtl/tsan_rtl_report.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_rtl_report.cc ------------------------------------------------===//
+//===-- tsan_rtl_report.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -27,7 +27,7 @@
namespace __tsan {
-using namespace __sanitizer; // NOLINT
+using namespace __sanitizer;
static ReportStack *SymbolizeStack(StackTrace trace);
@@ -154,6 +154,7 @@ ScopedReportBase::ScopedReportBase(ReportType typ, uptr tag) {
ScopedReportBase::~ScopedReportBase() {
ctx->report_mtx.Unlock();
DestroyAndFree(rep_);
+ rep_ = nullptr;
}
void ScopedReportBase::AddStack(StackTrace stack, bool suppressable) {
@@ -650,7 +651,7 @@ void ReportRace(ThreadState *thr) {
// and the resulting PC has kExternalPCBit set, so we pass it to
// __tsan_symbolize_external_ex. __tsan_symbolize_external_ex is within its
// rights to crash since the PC is completely bogus.
- // test/tsan/double_race.cc contains a test case for this.
+ // test/tsan/double_race.cpp contains a test case for this.
toppc = 0;
}
ObtainCurrentStack(thr, toppc, &traces[0], &tags[0]);
@@ -700,7 +701,7 @@ void ReportRace(ThreadState *thr) {
rep.AddLocation(addr_min, addr_max - addr_min);
#if !SANITIZER_GO
- { // NOLINT
+ {
Shadow s(thr->racy_state[1]);
if (s.epoch() <= thr->last_sleep_clock.get(s.tid()))
rep.AddSleep(thr->last_sleep_stack_id);
diff --git a/lib/tsan/rtl/tsan_rtl_thread.cc b/lib/tsan/rtl/tsan_rtl_thread.cpp
index fd95cfed4f51..0ac1ee99c470 100644
--- a/lib/tsan/rtl/tsan_rtl_thread.cc
+++ b/lib/tsan/rtl/tsan_rtl_thread.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_rtl_thread.cc ------------------------------------------------===//
+//===-- tsan_rtl_thread.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_stack_trace.cc b/lib/tsan/rtl/tsan_stack_trace.cpp
index dbaca23c68aa..403a21ae4ae3 100644
--- a/lib/tsan/rtl/tsan_stack_trace.cc
+++ b/lib/tsan/rtl/tsan_stack_trace.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_stack_trace.cc -----------------------------------------------===//
+//===-- tsan_stack_trace.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_stat.cc b/lib/tsan/rtl/tsan_stat.cpp
index d23ff47d9af0..78f3cce91384 100644
--- a/lib/tsan/rtl/tsan_stat.cc
+++ b/lib/tsan/rtl/tsan_stat.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_stat.cc ------------------------------------------------------===//
+//===-- tsan_stat.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_suppressions.cc b/lib/tsan/rtl/tsan_suppressions.cpp
index b3eea9ab5869..a1c1bf81bf67 100644
--- a/lib/tsan/rtl/tsan_suppressions.cc
+++ b/lib/tsan/rtl/tsan_suppressions.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_suppressions.cc ----------------------------------------------===//
+//===-- tsan_suppressions.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -50,7 +50,7 @@ static const char *kSuppressionTypes[] = {
void InitializeSuppressions() {
CHECK_EQ(nullptr, suppression_ctx);
- suppression_ctx = new (suppression_placeholder) // NOLINT
+ suppression_ctx = new (suppression_placeholder)
SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes));
suppression_ctx->ParseFromFile(flags()->suppressions);
#if !SANITIZER_GO
diff --git a/lib/tsan/rtl/tsan_symbolize.cc b/lib/tsan/rtl/tsan_symbolize.cpp
index cb60763f42f8..6478f3a754ac 100644
--- a/lib/tsan/rtl/tsan_symbolize.cc
+++ b/lib/tsan/rtl/tsan_symbolize.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_symbolize.cc -------------------------------------------------===//
+//===-- tsan_symbolize.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lib/tsan/rtl/tsan_sync.cc b/lib/tsan/rtl/tsan_sync.cpp
index c613b116e3a8..7f686dc5fcdc 100644
--- a/lib/tsan/rtl/tsan_sync.cc
+++ b/lib/tsan/rtl/tsan_sync.cpp
@@ -1,4 +1,4 @@
-//===-- tsan_sync.cc ------------------------------------------------------===//
+//===-- tsan_sync.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.