From 92287a8f345a545a9716d2dd105153d2885f32a1 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Wed, 29 Jan 2025 13:21:55 +0000 Subject: [PATCH] Add logging to help with CI deadlock. --- src/test/func/protect_fork/protect_fork.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/test/func/protect_fork/protect_fork.cc b/src/test/func/protect_fork/protect_fork.cc index 565870a56..28a8f4c7a 100644 --- a/src/test/func/protect_fork/protect_fork.cc +++ b/src/test/func/protect_fork/protect_fork.cc @@ -27,24 +27,33 @@ int main() size_t N = 3; + snmalloc::message<1024>("Testing PreventFork"); + + snmalloc::message<1024>("Adding alternative calls to pthread_atfork"); pthread_atfork(simulate_allocation, simulate_allocation, simulate_allocation); + + snmalloc::message<1024>("Initialising PreventFork singleton"); { // Cause initialisation of the PreventFork singleton to call pthread_atfork. snmalloc::PreventFork pf; } + + snmalloc::message<1024>("Adding alternative calls to pthread_atfork"); pthread_atfork(simulate_allocation, simulate_allocation, simulate_allocation); + snmalloc::message<1024>("Creating other threads"); for (size_t i = 0; i < N; i++) { - std::thread t([&block, &forking]() { + std::thread t([&block, &forking, i]() { { snmalloc::PreventFork pf; + snmalloc::message<1024>("Thread {} blocking fork", i); block++; std::this_thread::sleep_for(std::chrono::milliseconds(100)); while (!forking) std::this_thread::yield(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); - + snmalloc::message<1024>("Thread {} releasing block", i); block--; } }); @@ -52,11 +61,12 @@ int main() t.detach(); } + snmalloc::message<1024>("Waiting for all threads to block fork"); while (block != N) std::this_thread::yield(); + snmalloc::message<1024>("Forking"); forking = true; - fork(); if (block)