From 0b1f2a2fc614c2e7a2218514fe16e85c4d4e48e1 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 5 Dec 2025 11:44:42 +0100 Subject: catch exception leaks in windows thread pool (#677) * catch exception leaks in windows thread pool * make non-assert exception an error, assert is kept as warning as it is already reported --- src/zencore/workthreadpool.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/zencore/workthreadpool.cpp') diff --git a/src/zencore/workthreadpool.cpp b/src/zencore/workthreadpool.cpp index e241c0de8..cb84bbe06 100644 --- a/src/zencore/workthreadpool.cpp +++ b/src/zencore/workthreadpool.cpp @@ -156,8 +156,22 @@ struct WorkerThreadPool::Impl m_WorkQueue.pop_front(); } - ZEN_TRACE_CPU_FLUSH("AsyncWork"); - WorkFromQueue->Execute(); + try + { + ZEN_TRACE_CPU_FLUSH("AsyncWork"); + WorkFromQueue->Execute(); + WorkFromQueue = {}; + } + catch (const AssertException& Ex) + { + WorkFromQueue = {}; + ZEN_WARN("Assert exception in worker thread: {}", Ex.FullDescription()); + } + catch (const std::exception& e) + { + WorkFromQueue = {}; + ZEN_ERROR("Caught exception when executing worker synchronously: {}", e.what()); + } } }; @@ -264,7 +278,7 @@ WorkerThreadPool::Impl::WorkerThreadFunction(ThreadStartInfo Info) catch (const std::exception& e) { Work = {}; - ZEN_WARN("Caught exception in worker thread: {}", e.what()); + ZEN_ERROR("Caught exception in worker thread: {}", e.what()); } } else @@ -319,7 +333,7 @@ WorkerThreadPool::ScheduleWork(Ref Work, EMode Mode) catch (const std::exception& e) { Work = {}; - ZEN_WARN("Caught exception when executing worker synchronously: {}", e.what()); + ZEN_ERROR("Caught exception when executing worker synchronously: {}", e.what()); } } -- cgit v1.2.3