aboutsummaryrefslogtreecommitdiff
path: root/libsanitizer/tsan/tsan_platform_linux.cpp
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-10-06 10:24:24 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-10-06 13:08:47 -0700
commit2e3d50c09519d1b4899845b21843bae66ecffc2f (patch)
tree1c5ac48bcb8a3893f929c68d5e470913d4d31f97 /libsanitizer/tsan/tsan_platform_linux.cpp
parent881d1689a42cc7a1fd63bde53c883e52a56eded3 (diff)
downloadgcc-2e3d50c09519d1b4899845b21843bae66ecffc2f.zip
gcc-2e3d50c09519d1b4899845b21843bae66ecffc2f.tar.gz
gcc-2e3d50c09519d1b4899845b21843bae66ecffc2f.tar.bz2
libsanitizer: Merge with upstream
Merged revision: fdf4c035225de52f596899931b1f6100e5e3e928
Diffstat (limited to 'libsanitizer/tsan/tsan_platform_linux.cpp')
-rw-r--r--libsanitizer/tsan/tsan_platform_linux.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/libsanitizer/tsan/tsan_platform_linux.cpp b/libsanitizer/tsan/tsan_platform_linux.cpp
index 6134a1b..2fb753d 100644
--- a/libsanitizer/tsan/tsan_platform_linux.cpp
+++ b/libsanitizer/tsan/tsan_platform_linux.cpp
@@ -124,13 +124,13 @@ void WriteMemoryProfile(char *buf, uptr buf_size, u64 uptime_ns) {
internal_memset(mem, 0, sizeof(mem));
GetMemoryProfile(FillProfileCallback, mem, MemCount);
auto meta = ctx->metamap.GetMemoryStats();
- StackDepotStats *stacks = StackDepotGetStats();
+ StackDepotStats stacks = StackDepotGetStats();
uptr nthread, nlive;
ctx->thread_registry.GetNumberOfThreads(&nthread, &nlive);
uptr internal_stats[AllocatorStatCount];
internal_allocator()->GetStats(internal_stats);
// All these are allocated from the common mmap region.
- mem[MemMmap] -= meta.mem_block + meta.sync_obj + stacks->allocated +
+ mem[MemMmap] -= meta.mem_block + meta.sync_obj + stacks.allocated +
internal_stats[AllocatorStatMapped];
if (s64(mem[MemMmap]) < 0)
mem[MemMmap] = 0;
@@ -143,8 +143,8 @@ void WriteMemoryProfile(char *buf, uptr buf_size, u64 uptime_ns) {
mem[MemShadow] >> 20, mem[MemMeta] >> 20, mem[MemFile] >> 20,
mem[MemMmap] >> 20, mem[MemTrace] >> 20, mem[MemHeap] >> 20,
mem[MemOther] >> 20, internal_stats[AllocatorStatMapped] >> 20,
- meta.mem_block >> 20, meta.sync_obj >> 20, stacks->allocated >> 20,
- stacks->n_uniq_ids, nlive, nthread);
+ meta.mem_block >> 20, meta.sync_obj >> 20, stacks.allocated >> 20,
+ stacks.n_uniq_ids, nlive, nthread);
}
# if SANITIZER_LINUX
@@ -456,12 +456,14 @@ static void InitializeLongjmpXorKey() {
extern "C" void __tsan_tls_initialization() {}
void ImitateTlsWrite(ThreadState *thr, uptr tls_addr, uptr tls_size) {
+ // Check that the thr object is in tls;
const uptr thr_beg = (uptr)thr;
const uptr thr_end = (uptr)thr + sizeof(*thr);
- // ThreadState is normally allocated in TLS and is large,
- // so we skip it. But unit tests allocate ThreadState outside of TLS.
- if (thr_beg < tls_addr || thr_end >= tls_addr + tls_size)
- return;
+ CHECK_GE(thr_beg, tls_addr);
+ CHECK_LE(thr_beg, tls_addr + tls_size);
+ CHECK_GE(thr_end, tls_addr);
+ CHECK_LE(thr_end, tls_addr + tls_size);
+ // Since the thr object is huge, skip it.
const uptr pc = StackTrace::GetNextInstructionPc(
reinterpret_cast<uptr>(__tsan_tls_initialization));
MemoryRangeImitateWrite(thr, pc, tls_addr, thr_beg - tls_addr);