[GWP-ASan] Fix atfork handlers being installed multiple times in tests

We incorrectly install the atfork handlers multiple times in the test
harness, tracked down to the default parameter used by
CheckLateInitIsOK. This manifested in a hang if running the tests with
--gtest_repeat={>=2} as the atfork handler ran multiple times, causing
double-lock and double-unlock, which on my machine hung.

Add a check-fail for this case as well to prevent this from happening
again (it was difficult to track down and is an easy mistake to make).

Differential Revision: https://reviews.llvm.org/D139731
This commit is contained in:
Mitch Phillips 2023-01-10 10:16:03 -08:00
parent fd7273359a
commit 296f7fbbb5

View File

@ -98,6 +98,10 @@ size_t GuardedPoolAllocator::getPlatformPageSize() {
}
void GuardedPoolAllocator::installAtFork() {
static bool AtForkInstalled = false;
if (AtForkInstalled)
return;
AtForkInstalled = true;
auto Disable = []() {
if (auto *S = getSingleton())
S->disable();