From 5182e007931b2ebf034d1a9ed42737ed30b2ac13 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Aug 2024 09:35:31 +0200 Subject: Don't work own queue in wait_guard dtor There is suspicion this causes a deadlock for reasons so far unclear. See also GH issue #319. --- libbuild2/context.hxx | 2 +- libbuild2/context.ixx | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx index 33fc892..828c41e 100644 --- a/libbuild2/context.hxx +++ b/libbuild2/context.hxx @@ -904,7 +904,7 @@ namespace build2 bool unlock_phase = false); void - wait (); + wait (bool work_queue = true); // Note: move-assignable to empty only. // diff --git a/libbuild2/context.ixx b/libbuild2/context.ixx index 6c8c428..2c62a45 100644 --- a/libbuild2/context.ixx +++ b/libbuild2/context.ixx @@ -26,8 +26,11 @@ namespace build2 inline wait_guard:: ~wait_guard () noexcept (false) { + // Don't work our own queue since we are most likely in stack unwinding + // causes by an exception. + // if (task_count != nullptr) - wait (); + wait (false); } inline wait_guard:: @@ -54,10 +57,15 @@ namespace build2 } inline void wait_guard:: - wait () + wait (bool wq) { phase_unlock u (phase ? ctx : nullptr, true /* delay */); - ctx->sched->wait (start_count, *task_count, u); + ctx->sched->wait (start_count, + *task_count, + u, + (wq + ? scheduler::work_queue::work_all + : scheduler::work_queue::work_none)); task_count = nullptr; } } -- cgit v1.1