[PATCH] D40294: Prevent Thread Exited/Joined events race
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 04:18:13 PST 2017
krytarowski created this revision.
krytarowski added a project: Sanitizers.
Herald added a subscriber: kubamracek.
This change modifies TSan and LSan.
It is required for NetBSD in order to prevent Thread Exited/Joined race,
that may occur when native system libpthread(3) cannot be reliably traced
in a way to guarantee that the mentioned events happen one after another.
Rename the ThreadTid() functions to ThreadTctx and change return type
from u32 to ThreadContextBase*.
Store atomic integer inside the ThreadContextBase structure of the exiting
and joining thread.
Add a signal/wait-like mechanism: notify that the thread has been destroyed,
and add a spin loop in the pthread_join(3) interceptor waiting for the destroy
of the event (ThreadFinish()) to accomplish.
LSan requires the same changes in future, once it will be ported to NetBSD.
Sponsored by <The NetBSD Foundation>
Repository:
rL LLVM
https://reviews.llvm.org/D40294
Files:
lib/lsan/lsan_interceptors.cc
lib/lsan/lsan_thread.cc
lib/lsan/lsan_thread.h
lib/sanitizer_common/sanitizer_thread_registry.cc
lib/sanitizer_common/sanitizer_thread_registry.h
lib/tsan/rtl/tsan_interceptors.cc
lib/tsan/rtl/tsan_rtl.h
lib/tsan/rtl/tsan_rtl_thread.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40294.123761.patch
Type: text/x-patch
Size: 6416 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171121/c9d61e6d/attachment.bin>
More information about the llvm-commits
mailing list