[all-commits] [llvm/llvm-project] e1021d: tsan: refactor fork handling
Dmitry Vyukov via All-commits
all-commits at lists.llvm.org
Tue Apr 27 13:37:57 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e1021dd1fdfebff77cfb205892ada6b6a900865f
https://github.com/llvm/llvm-project/commit/e1021dd1fdfebff77cfb205892ada6b6a900865f
Author: Dmitry Vyukov <dvyukov at google.com>
Date: 2021-04-27 (Tue, 27 Apr 2021)
Changed paths:
M compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
M compiler-rt/lib/tsan/rtl/tsan_mman.cpp
M compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
M compiler-rt/lib/tsan/rtl/tsan_rtl.h
M compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
M compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
M compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
M compiler-rt/test/tsan/pthread_atfork_deadlock.c
M compiler-rt/test/tsan/pthread_atfork_deadlock2.c
A compiler-rt/test/tsan/pthread_atfork_deadlock3.c
Log Message:
-----------
tsan: refactor fork handling
Commit efd254b6362 ("tsan: fix deadlock in pthread_atfork callbacks")
fixed another deadlock related to atfork handling.
But builders with DCHECKs enabled reported failures of
pthread_atfork_deadlock2.c and pthread_atfork_deadlock3.c tests
related to the fact that we hold runtime locks on interceptor exit:
https://lab.llvm.org/buildbot/#/builders/70/builds/6727
This issue is somewhat inherent to the current approach,
we indeed execute user code (atfork callbacks) with runtime lock held.
Refactor fork handling to not run user code (atfork callbacks)
with runtime locks held. This change does this by installing
own atfork callbacks during runtime initialization.
Atfork callbacks run in LIFO order, so the expectation is that
our callbacks run last, right before the actual fork.
This way we lock runtime mutexes around fork, but not around
user callbacks.
Extend tests to also install after fork callbacks just to cover
more scenarios. Some tests also started reporting real races
that we previously suppressed.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D101385
More information about the All-commits
mailing list