[all-commits] [llvm/llvm-project] 9ef6fa: [scudo][standalone] Fork support
Kostya Kortchinsky via All-commits
all-commits at lists.llvm.org
Tue Jan 14 07:51:59 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 9ef6faf49670e18eb1ba04105a7c70b450cdaa71
https://github.com/llvm/llvm-project/commit/9ef6faf49670e18eb1ba04105a7c70b450cdaa71
Author: Kostya Kortchinsky <kostyak at google.com>
Date: 2020-01-14 (Tue, 14 Jan 2020)
Changed paths:
M compiler-rt/lib/scudo/standalone/CMakeLists.txt
M compiler-rt/lib/scudo/standalone/bytemap.h
M compiler-rt/lib/scudo/standalone/combined.h
M compiler-rt/lib/scudo/standalone/primary32.h
M compiler-rt/lib/scudo/standalone/primary64.h
M compiler-rt/lib/scudo/standalone/quarantine.h
M compiler-rt/lib/scudo/standalone/stats.h
M compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
M compiler-rt/lib/scudo/standalone/tests/tsd_test.cpp
M compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
M compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp
M compiler-rt/lib/scudo/standalone/tsd.h
M compiler-rt/lib/scudo/standalone/tsd_exclusive.h
M compiler-rt/lib/scudo/standalone/tsd_shared.h
M compiler-rt/lib/scudo/standalone/wrappers_c.cpp
M compiler-rt/lib/scudo/standalone/wrappers_c.inc
M compiler-rt/lib/scudo/standalone/wrappers_c_bionic.cpp
M compiler-rt/lib/scudo/standalone/wrappers_cpp.cpp
Log Message:
-----------
[scudo][standalone] Fork support
Summary:
fork() wasn't well (or at all) supported in Scudo. This materialized
in deadlocks in children.
In order to properly support fork, we will lock the allocator pre-fork
and unlock it post-fork in parent and child. This is done via a
`pthread_atfork` call installing the necessary handlers.
A couple of things suck here: this function allocates - so this has to
be done post initialization as our init path is not reentrance, and it
doesn't allow for an extra pointer - so we can't pass the allocator we
are currently working with.
In order to work around this, I added a post-init template parameter
that gets executed once the allocator is initialized for the current
thread. Its job for the C wrappers is to install the atfork handlers.
I reorganized a bit the impacted area and added some tests, courtesy
of cferris@ that were deadlocking prior to this fix.
Subscribers: jfb, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D72470
More information about the All-commits
mailing list