From 3f7ccc00e7c7bd7563866c86322e221028d77e00 Mon Sep 17 00:00:00 2001 From: Georgiy Belyanin Date: Sat, 14 Jun 2025 11:07:57 +0300 Subject: [PATCH] Fix spurious continue in the debug mode This patch fixes the problem I came across when tried to use the debugger on MacOS with arm64. When Lua hit breakpoint it captured it though the program execution did not stop since the debug loop exited almost instantly. Debug prints showed that this happened due to the spurious wake ups of the conditional variable `cvRun`. None of the methods notified this conditional so it seems it is a spurious wake up. Probably it is specific to the architecture. This small patch fixes this by adding a predicate to the conditional variable. It waits until the debugging is finished or there are evals to run. --- emmy_debugger/src/debugger/emmy_debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emmy_debugger/src/debugger/emmy_debugger.cpp b/emmy_debugger/src/debugger/emmy_debugger.cpp index 0b13a72..b6d76f6 100644 --- a/emmy_debugger/src/debugger/emmy_debugger.cpp +++ b/emmy_debugger/src/debugger/emmy_debugger.cpp @@ -660,7 +660,7 @@ void Debugger::EnterDebugMode() { std::unique_lock lockEval(evalMtx); if (evalQueue.empty() && blocking) { lockEval.unlock(); - cvRun.wait(lock); + cvRun.wait(lock, [this] { return !blocking || !evalQueue.empty(); }); lockEval.lock(); } if (!evalQueue.empty()) {