From c29c61f840aa317a6dd887a35fffbc60a78d87a9 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Sun, 6 Nov 2022 15:04:47 +0100 Subject: Fix T102292: deadlock in geometry nodes evaluation with task isolation As described in the comment on `BLI_task_isolate`, deadlocks can happen when isolation is used with threading primitives that separate spawning tasks from executing them. All threads are waiting the tasks to complete but no thread is able to continue working due to task isolation. The fix is to not pass lazy-threading hints through task isolations. This way isolated regions can't create new tasks in a scheduler further up the call stack. This may lead to minor slowdowns because less threading may be used. It's generally possible to get rid of the slowdown again by sending the lazy-threading hint before entering the isolated region. --- source/blender/blenlib/intern/task_scheduler.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenlib/intern/task_scheduler.cc') diff --git a/source/blender/blenlib/intern/task_scheduler.cc b/source/blender/blenlib/intern/task_scheduler.cc index 1f7747453c1..5b056df78b4 100644 --- a/source/blender/blenlib/intern/task_scheduler.cc +++ b/source/blender/blenlib/intern/task_scheduler.cc @@ -8,6 +8,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_lazy_threading.hh" #include "BLI_task.h" #include "BLI_threads.h" @@ -67,6 +68,7 @@ int BLI_task_scheduler_num_threads() void BLI_task_isolate(void (*func)(void *userdata), void *userdata) { #ifdef WITH_TBB + blender::lazy_threading::ReceiverIsolation isolation; tbb::this_task_arena::isolate([&] { func(userdata); }); #else func(userdata); -- cgit v1.2.3