tsan_platform_linux.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. //===-- tsan_platform_linux.cpp -------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file is a part of ThreadSanitizer (TSan), a race detector.
  10. //
  11. // Linux- and BSD-specific code.
  12. //===----------------------------------------------------------------------===//
  13. #include "sanitizer_common/sanitizer_platform.h"
  14. #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
  15. #include "sanitizer_common/sanitizer_common.h"
  16. #include "sanitizer_common/sanitizer_libc.h"
  17. #include "sanitizer_common/sanitizer_linux.h"
  18. #include "sanitizer_common/sanitizer_platform_limits_netbsd.h"
  19. #include "sanitizer_common/sanitizer_platform_limits_posix.h"
  20. #include "sanitizer_common/sanitizer_posix.h"
  21. #include "sanitizer_common/sanitizer_procmaps.h"
  22. #include "sanitizer_common/sanitizer_stackdepot.h"
  23. #include "sanitizer_common/sanitizer_stoptheworld.h"
  24. #include "tsan_flags.h"
  25. #include "tsan_platform.h"
  26. #include "tsan_rtl.h"
  27. #include <fcntl.h>
  28. #include <pthread.h>
  29. #include <signal.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <stdarg.h>
  34. #include <sys/mman.h>
  35. #if SANITIZER_LINUX
  36. #include <sys/personality.h>
  37. #include <setjmp.h>
  38. #endif
  39. #include <sys/syscall.h>
  40. #include <sys/socket.h>
  41. #include <sys/time.h>
  42. #include <sys/types.h>
  43. #include <sys/resource.h>
  44. #include <sys/stat.h>
  45. #include <unistd.h>
  46. #include <sched.h>
  47. #include <dlfcn.h>
  48. #if SANITIZER_LINUX
  49. #define __need_res_state
  50. #include <resolv.h>
  51. #endif
  52. #ifdef sa_handler
  53. # undef sa_handler
  54. #endif
  55. #ifdef sa_sigaction
  56. # undef sa_sigaction
  57. #endif
  58. #if SANITIZER_FREEBSD
  59. extern "C" void *__libc_stack_end;
  60. void *__libc_stack_end = 0;
  61. #endif
  62. #if SANITIZER_LINUX && defined(__aarch64__) && !SANITIZER_GO
  63. # define INIT_LONGJMP_XOR_KEY 1
  64. #else
  65. # define INIT_LONGJMP_XOR_KEY 0
  66. #endif
  67. #if INIT_LONGJMP_XOR_KEY
  68. #include "interception/interception.h"
  69. // Must be declared outside of other namespaces.
  70. DECLARE_REAL(int, _setjmp, void *env)
  71. #endif
  72. namespace __tsan {
  73. #if INIT_LONGJMP_XOR_KEY
  74. static void InitializeLongjmpXorKey();
  75. static uptr longjmp_xor_key;
  76. #endif
  77. // Runtime detected VMA size.
  78. uptr vmaSize;
  79. enum {
  80. MemTotal,
  81. MemShadow,
  82. MemMeta,
  83. MemFile,
  84. MemMmap,
  85. MemHeap,
  86. MemOther,
  87. MemCount,
  88. };
  89. void FillProfileCallback(uptr p, uptr rss, bool file, uptr *mem) {
  90. mem[MemTotal] += rss;
  91. if (p >= ShadowBeg() && p < ShadowEnd())
  92. mem[MemShadow] += rss;
  93. else if (p >= MetaShadowBeg() && p < MetaShadowEnd())
  94. mem[MemMeta] += rss;
  95. else if ((p >= LoAppMemBeg() && p < LoAppMemEnd()) ||
  96. (p >= MidAppMemBeg() && p < MidAppMemEnd()) ||
  97. (p >= HiAppMemBeg() && p < HiAppMemEnd()))
  98. mem[file ? MemFile : MemMmap] += rss;
  99. else if (p >= HeapMemBeg() && p < HeapMemEnd())
  100. mem[MemHeap] += rss;
  101. else
  102. mem[MemOther] += rss;
  103. }
  104. void WriteMemoryProfile(char *buf, uptr buf_size, u64 uptime_ns) {
  105. uptr mem[MemCount];
  106. internal_memset(mem, 0, sizeof(mem));
  107. GetMemoryProfile(FillProfileCallback, mem);
  108. auto meta = ctx->metamap.GetMemoryStats();
  109. StackDepotStats stacks = StackDepotGetStats();
  110. uptr nthread, nlive;
  111. ctx->thread_registry.GetNumberOfThreads(&nthread, &nlive);
  112. uptr trace_mem;
  113. {
  114. Lock l(&ctx->slot_mtx);
  115. trace_mem = ctx->trace_part_total_allocated * sizeof(TracePart);
  116. }
  117. uptr internal_stats[AllocatorStatCount];
  118. internal_allocator()->GetStats(internal_stats);
  119. // All these are allocated from the common mmap region.
  120. mem[MemMmap] -= meta.mem_block + meta.sync_obj + trace_mem +
  121. stacks.allocated + internal_stats[AllocatorStatMapped];
  122. if (s64(mem[MemMmap]) < 0)
  123. mem[MemMmap] = 0;
  124. internal_snprintf(
  125. buf, buf_size,
  126. "==%zu== %llus [%zu]: RSS %zd MB: shadow:%zd meta:%zd file:%zd"
  127. " mmap:%zd heap:%zd other:%zd intalloc:%zd memblocks:%zd syncobj:%zu"
  128. " trace:%zu stacks=%zd threads=%zu/%zu\n",
  129. internal_getpid(), uptime_ns / (1000 * 1000 * 1000), ctx->global_epoch,
  130. mem[MemTotal] >> 20, mem[MemShadow] >> 20, mem[MemMeta] >> 20,
  131. mem[MemFile] >> 20, mem[MemMmap] >> 20, mem[MemHeap] >> 20,
  132. mem[MemOther] >> 20, internal_stats[AllocatorStatMapped] >> 20,
  133. meta.mem_block >> 20, meta.sync_obj >> 20, trace_mem >> 20,
  134. stacks.allocated >> 20, nlive, nthread);
  135. }
  136. #if !SANITIZER_GO
  137. // Mark shadow for .rodata sections with the special Shadow::kRodata marker.
  138. // Accesses to .rodata can't race, so this saves time, memory and trace space.
  139. static void MapRodata() {
  140. // First create temp file.
  141. const char *tmpdir = GetEnv("TMPDIR");
  142. if (tmpdir == 0)
  143. tmpdir = GetEnv("TEST_TMPDIR");
  144. #ifdef P_tmpdir
  145. if (tmpdir == 0)
  146. tmpdir = P_tmpdir;
  147. #endif
  148. if (tmpdir == 0)
  149. return;
  150. char name[256];
  151. internal_snprintf(name, sizeof(name), "%s/tsan.rodata.%d",
  152. tmpdir, (int)internal_getpid());
  153. uptr openrv = internal_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
  154. if (internal_iserror(openrv))
  155. return;
  156. internal_unlink(name); // Unlink it now, so that we can reuse the buffer.
  157. fd_t fd = openrv;
  158. // Fill the file with Shadow::kRodata.
  159. const uptr kMarkerSize = 512 * 1024 / sizeof(RawShadow);
  160. InternalMmapVector<RawShadow> marker(kMarkerSize);
  161. // volatile to prevent insertion of memset
  162. for (volatile RawShadow *p = marker.data(); p < marker.data() + kMarkerSize;
  163. p++)
  164. *p = Shadow::kRodata;
  165. internal_write(fd, marker.data(), marker.size() * sizeof(RawShadow));
  166. // Map the file into memory.
  167. uptr page = internal_mmap(0, GetPageSizeCached(), PROT_READ | PROT_WRITE,
  168. MAP_PRIVATE | MAP_ANONYMOUS, fd, 0);
  169. if (internal_iserror(page)) {
  170. internal_close(fd);
  171. return;
  172. }
  173. // Map the file into shadow of .rodata sections.
  174. MemoryMappingLayout proc_maps(/*cache_enabled*/true);
  175. // Reusing the buffer 'name'.
  176. MemoryMappedSegment segment(name, ARRAY_SIZE(name));
  177. while (proc_maps.Next(&segment)) {
  178. if (segment.filename[0] != 0 && segment.filename[0] != '[' &&
  179. segment.IsReadable() && segment.IsExecutable() &&
  180. !segment.IsWritable() && IsAppMem(segment.start)) {
  181. // Assume it's .rodata
  182. char *shadow_start = (char *)MemToShadow(segment.start);
  183. char *shadow_end = (char *)MemToShadow(segment.end);
  184. for (char *p = shadow_start; p < shadow_end;
  185. p += marker.size() * sizeof(RawShadow)) {
  186. internal_mmap(
  187. p, Min<uptr>(marker.size() * sizeof(RawShadow), shadow_end - p),
  188. PROT_READ, MAP_PRIVATE | MAP_FIXED, fd, 0);
  189. }
  190. }
  191. }
  192. internal_close(fd);
  193. }
  194. void InitializeShadowMemoryPlatform() {
  195. MapRodata();
  196. }
  197. #endif // #if !SANITIZER_GO
  198. void InitializePlatformEarly() {
  199. vmaSize =
  200. (MostSignificantSetBitIndex(GET_CURRENT_FRAME()) + 1);
  201. #if defined(__aarch64__)
  202. # if !SANITIZER_GO
  203. if (vmaSize != 39 && vmaSize != 42 && vmaSize != 48) {
  204. Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
  205. Printf("FATAL: Found %zd - Supported 39, 42 and 48\n", vmaSize);
  206. Die();
  207. }
  208. #else
  209. if (vmaSize != 48) {
  210. Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
  211. Printf("FATAL: Found %zd - Supported 48\n", vmaSize);
  212. Die();
  213. }
  214. #endif
  215. #elif defined(__powerpc64__)
  216. # if !SANITIZER_GO
  217. if (vmaSize != 44 && vmaSize != 46 && vmaSize != 47) {
  218. Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
  219. Printf("FATAL: Found %zd - Supported 44, 46, and 47\n", vmaSize);
  220. Die();
  221. }
  222. # else
  223. if (vmaSize != 46 && vmaSize != 47) {
  224. Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
  225. Printf("FATAL: Found %zd - Supported 46, and 47\n", vmaSize);
  226. Die();
  227. }
  228. # endif
  229. #elif defined(__mips64)
  230. # if !SANITIZER_GO
  231. if (vmaSize != 40) {
  232. Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
  233. Printf("FATAL: Found %zd - Supported 40\n", vmaSize);
  234. Die();
  235. }
  236. # else
  237. if (vmaSize != 47) {
  238. Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
  239. Printf("FATAL: Found %zd - Supported 47\n", vmaSize);
  240. Die();
  241. }
  242. # endif
  243. #endif
  244. }
  245. void InitializePlatform() {
  246. DisableCoreDumperIfNecessary();
  247. // Go maps shadow memory lazily and works fine with limited address space.
  248. // Unlimited stack is not a problem as well, because the executable
  249. // is not compiled with -pie.
  250. #if !SANITIZER_GO
  251. {
  252. bool reexec = false;
  253. // TSan doesn't play well with unlimited stack size (as stack
  254. // overlaps with shadow memory). If we detect unlimited stack size,
  255. // we re-exec the program with limited stack size as a best effort.
  256. if (StackSizeIsUnlimited()) {
  257. const uptr kMaxStackSize = 32 * 1024 * 1024;
  258. VReport(1, "Program is run with unlimited stack size, which wouldn't "
  259. "work with ThreadSanitizer.\n"
  260. "Re-execing with stack size limited to %zd bytes.\n",
  261. kMaxStackSize);
  262. SetStackSizeLimitInBytes(kMaxStackSize);
  263. reexec = true;
  264. }
  265. if (!AddressSpaceIsUnlimited()) {
  266. Report("WARNING: Program is run with limited virtual address space,"
  267. " which wouldn't work with ThreadSanitizer.\n");
  268. Report("Re-execing with unlimited virtual address space.\n");
  269. SetAddressSpaceUnlimited();
  270. reexec = true;
  271. }
  272. #if SANITIZER_LINUX && defined(__aarch64__)
  273. // After patch "arm64: mm: support ARCH_MMAP_RND_BITS." is introduced in
  274. // linux kernel, the random gap between stack and mapped area is increased
  275. // from 128M to 36G on 39-bit aarch64. As it is almost impossible to cover
  276. // this big range, we should disable randomized virtual space on aarch64.
  277. int old_personality = personality(0xffffffff);
  278. if (old_personality != -1 && (old_personality & ADDR_NO_RANDOMIZE) == 0) {
  279. VReport(1, "WARNING: Program is run with randomized virtual address "
  280. "space, which wouldn't work with ThreadSanitizer.\n"
  281. "Re-execing with fixed virtual address space.\n");
  282. CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1);
  283. reexec = true;
  284. }
  285. // Initialize the xor key used in {sig}{set,long}jump.
  286. InitializeLongjmpXorKey();
  287. #endif
  288. if (reexec)
  289. ReExec();
  290. }
  291. CheckAndProtect();
  292. InitTlsSize();
  293. #endif // !SANITIZER_GO
  294. }
  295. #if !SANITIZER_GO
  296. // Extract file descriptors passed to glibc internal __res_iclose function.
  297. // This is required to properly "close" the fds, because we do not see internal
  298. // closes within glibc. The code is a pure hack.
  299. int ExtractResolvFDs(void *state, int *fds, int nfd) {
  300. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  301. int cnt = 0;
  302. struct __res_state *statp = (struct __res_state*)state;
  303. for (int i = 0; i < MAXNS && cnt < nfd; i++) {
  304. if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
  305. fds[cnt++] = statp->_u._ext.nssocks[i];
  306. }
  307. return cnt;
  308. #else
  309. return 0;
  310. #endif
  311. }
  312. // Extract file descriptors passed via UNIX domain sockets.
  313. // This is required to properly handle "open" of these fds.
  314. // see 'man recvmsg' and 'man 3 cmsg'.
  315. int ExtractRecvmsgFDs(void *msgp, int *fds, int nfd) {
  316. int res = 0;
  317. msghdr *msg = (msghdr*)msgp;
  318. struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg);
  319. for (; cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
  320. if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS)
  321. continue;
  322. int n = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(fds[0]);
  323. for (int i = 0; i < n; i++) {
  324. fds[res++] = ((int*)CMSG_DATA(cmsg))[i];
  325. if (res == nfd)
  326. return res;
  327. }
  328. }
  329. return res;
  330. }
  331. // Reverse operation of libc stack pointer mangling
  332. static uptr UnmangleLongJmpSp(uptr mangled_sp) {
  333. #if defined(__x86_64__)
  334. # if SANITIZER_LINUX
  335. // Reverse of:
  336. // xor %fs:0x30, %rsi
  337. // rol $0x11, %rsi
  338. uptr sp;
  339. asm("ror $0x11, %0 \n"
  340. "xor %%fs:0x30, %0 \n"
  341. : "=r" (sp)
  342. : "0" (mangled_sp));
  343. return sp;
  344. # else
  345. return mangled_sp;
  346. # endif
  347. #elif defined(__aarch64__)
  348. # if SANITIZER_LINUX
  349. return mangled_sp ^ longjmp_xor_key;
  350. # else
  351. return mangled_sp;
  352. # endif
  353. #elif defined(__powerpc64__)
  354. // Reverse of:
  355. // ld r4, -28696(r13)
  356. // xor r4, r3, r4
  357. uptr xor_key;
  358. asm("ld %0, -28696(%%r13)" : "=r" (xor_key));
  359. return mangled_sp ^ xor_key;
  360. #elif defined(__mips__)
  361. return mangled_sp;
  362. #elif defined(__s390x__)
  363. // tcbhead_t.stack_guard
  364. uptr xor_key = ((uptr *)__builtin_thread_pointer())[5];
  365. return mangled_sp ^ xor_key;
  366. #else
  367. #error "Unknown platform"
  368. #endif
  369. }
  370. #if SANITIZER_NETBSD
  371. # ifdef __x86_64__
  372. # define LONG_JMP_SP_ENV_SLOT 6
  373. # else
  374. # error unsupported
  375. # endif
  376. #elif defined(__powerpc__)
  377. # define LONG_JMP_SP_ENV_SLOT 0
  378. #elif SANITIZER_FREEBSD
  379. # define LONG_JMP_SP_ENV_SLOT 2
  380. #elif SANITIZER_LINUX
  381. # ifdef __aarch64__
  382. # define LONG_JMP_SP_ENV_SLOT 13
  383. # elif defined(__mips64)
  384. # define LONG_JMP_SP_ENV_SLOT 1
  385. # elif defined(__s390x__)
  386. # define LONG_JMP_SP_ENV_SLOT 9
  387. # else
  388. # define LONG_JMP_SP_ENV_SLOT 6
  389. # endif
  390. #endif
  391. uptr ExtractLongJmpSp(uptr *env) {
  392. uptr mangled_sp = env[LONG_JMP_SP_ENV_SLOT];
  393. return UnmangleLongJmpSp(mangled_sp);
  394. }
  395. #if INIT_LONGJMP_XOR_KEY
  396. // GLIBC mangles the function pointers in jmp_buf (used in {set,long}*jmp
  397. // functions) by XORing them with a random key. For AArch64 it is a global
  398. // variable rather than a TCB one (as for x86_64/powerpc). We obtain the key by
  399. // issuing a setjmp and XORing the SP pointer values to derive the key.
  400. static void InitializeLongjmpXorKey() {
  401. // 1. Call REAL(setjmp), which stores the mangled SP in env.
  402. jmp_buf env;
  403. REAL(_setjmp)(env);
  404. // 2. Retrieve vanilla/mangled SP.
  405. uptr sp;
  406. asm("mov %0, sp" : "=r" (sp));
  407. uptr mangled_sp = ((uptr *)&env)[LONG_JMP_SP_ENV_SLOT];
  408. // 3. xor SPs to obtain key.
  409. longjmp_xor_key = mangled_sp ^ sp;
  410. }
  411. #endif
  412. extern "C" void __tsan_tls_initialization() {}
  413. void ImitateTlsWrite(ThreadState *thr, uptr tls_addr, uptr tls_size) {
  414. // Check that the thr object is in tls;
  415. const uptr thr_beg = (uptr)thr;
  416. const uptr thr_end = (uptr)thr + sizeof(*thr);
  417. CHECK_GE(thr_beg, tls_addr);
  418. CHECK_LE(thr_beg, tls_addr + tls_size);
  419. CHECK_GE(thr_end, tls_addr);
  420. CHECK_LE(thr_end, tls_addr + tls_size);
  421. // Since the thr object is huge, skip it.
  422. const uptr pc = StackTrace::GetNextInstructionPc(
  423. reinterpret_cast<uptr>(__tsan_tls_initialization));
  424. MemoryRangeImitateWrite(thr, pc, tls_addr, thr_beg - tls_addr);
  425. MemoryRangeImitateWrite(thr, pc, thr_end, tls_addr + tls_size - thr_end);
  426. }
  427. // Note: this function runs with async signals enabled,
  428. // so it must not touch any tsan state.
  429. int call_pthread_cancel_with_cleanup(int (*fn)(void *arg),
  430. void (*cleanup)(void *arg), void *arg) {
  431. // pthread_cleanup_push/pop are hardcore macros mess.
  432. // We can't intercept nor call them w/o including pthread.h.
  433. int res;
  434. pthread_cleanup_push(cleanup, arg);
  435. res = fn(arg);
  436. pthread_cleanup_pop(0);
  437. return res;
  438. }
  439. #endif // !SANITIZER_GO
  440. #if !SANITIZER_GO
  441. void ReplaceSystemMalloc() { }
  442. #endif
  443. #if !SANITIZER_GO
  444. #if SANITIZER_ANDROID
  445. // On Android, one thread can call intercepted functions after
  446. // DestroyThreadState(), so add a fake thread state for "dead" threads.
  447. static ThreadState *dead_thread_state = nullptr;
  448. ThreadState *cur_thread() {
  449. ThreadState* thr = reinterpret_cast<ThreadState*>(*get_android_tls_ptr());
  450. if (thr == nullptr) {
  451. __sanitizer_sigset_t emptyset;
  452. internal_sigfillset(&emptyset);
  453. __sanitizer_sigset_t oldset;
  454. CHECK_EQ(0, internal_sigprocmask(SIG_SETMASK, &emptyset, &oldset));
  455. thr = reinterpret_cast<ThreadState*>(*get_android_tls_ptr());
  456. if (thr == nullptr) {
  457. thr = reinterpret_cast<ThreadState*>(MmapOrDie(sizeof(ThreadState),
  458. "ThreadState"));
  459. *get_android_tls_ptr() = reinterpret_cast<uptr>(thr);
  460. if (dead_thread_state == nullptr) {
  461. dead_thread_state = reinterpret_cast<ThreadState*>(
  462. MmapOrDie(sizeof(ThreadState), "ThreadState"));
  463. dead_thread_state->fast_state.SetIgnoreBit();
  464. dead_thread_state->ignore_interceptors = 1;
  465. dead_thread_state->is_dead = true;
  466. *const_cast<u32*>(&dead_thread_state->tid) = -1;
  467. CHECK_EQ(0, internal_mprotect(dead_thread_state, sizeof(ThreadState),
  468. PROT_READ));
  469. }
  470. }
  471. CHECK_EQ(0, internal_sigprocmask(SIG_SETMASK, &oldset, nullptr));
  472. }
  473. return thr;
  474. }
  475. void set_cur_thread(ThreadState *thr) {
  476. *get_android_tls_ptr() = reinterpret_cast<uptr>(thr);
  477. }
  478. void cur_thread_finalize() {
  479. __sanitizer_sigset_t emptyset;
  480. internal_sigfillset(&emptyset);
  481. __sanitizer_sigset_t oldset;
  482. CHECK_EQ(0, internal_sigprocmask(SIG_SETMASK, &emptyset, &oldset));
  483. ThreadState* thr = reinterpret_cast<ThreadState*>(*get_android_tls_ptr());
  484. if (thr != dead_thread_state) {
  485. *get_android_tls_ptr() = reinterpret_cast<uptr>(dead_thread_state);
  486. UnmapOrDie(thr, sizeof(ThreadState));
  487. }
  488. CHECK_EQ(0, internal_sigprocmask(SIG_SETMASK, &oldset, nullptr));
  489. }
  490. #endif // SANITIZER_ANDROID
  491. #endif // if !SANITIZER_GO
  492. } // namespace __tsan
  493. #endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD