[PATCH] D58641: [winasan] Unpoison stack memory when threads exit (redux)
David Major via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 25 17:35:12 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354836: [winasan] Unpoison stack memory when threads exit (redux) (authored by dmajor, committed by ).
Herald added subscribers: delcypher, kubamracek.
Changed prior to commit:
https://reviews.llvm.org/D58641?vs=188229&id=188282#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58641/new/
https://reviews.llvm.org/D58641
Files:
compiler-rt/trunk/lib/asan/asan_win.cc
Index: compiler-rt/trunk/lib/asan/asan_win.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc
+++ compiler-rt/trunk/lib/asan/asan_win.cc
@@ -354,6 +354,19 @@
unsigned long, void *) = asan_thread_init;
#endif
+static void NTAPI asan_thread_exit(void *module, DWORD reason, void *reserved) {
+ if (reason == DLL_THREAD_DETACH) {
+ // Unpoison the thread's stack because the memory may be re-used.
+ NT_TIB *tib = (NT_TIB *)NtCurrentTeb();
+ uptr stackSize = (uptr)tib->StackBase - (uptr)tib->StackLimit;
+ __asan_unpoison_memory_region(tib->StackLimit, stackSize);
+ }
+}
+
+#pragma section(".CRT$XLY", long, read) // NOLINT
+__declspec(allocate(".CRT$XLY")) void (NTAPI *__asan_tls_exit)(void *,
+ unsigned long, void *) = asan_thread_exit;
+
WIN_FORCE_LINK(__asan_dso_reg_hook)
// }}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58641.188282.patch
Type: text/x-patch
Size: 878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190226/91a0e78a/attachment.bin>
More information about the llvm-commits
mailing list