summaryrefslogtreecommitdiff
path: root/core/object
diff options
context:
space:
mode:
authorSimo Haasanen <48187847+haasanen@users.noreply.github.com>2022-10-20 17:47:20 +0100
committerSimo Haasanen <48187847+haasanen@users.noreply.github.com>2022-10-20 17:47:20 +0100
commit4cc3489bc02a94e21145d8ec5910d65f591689ee (patch)
treee4bd8b708237a42752aa918cc39eea6283000ac0 /core/object
parenta8c805be2947b211ee8b881d7a8bab7cdc86e170 (diff)
Fixes HashMap::erase related race condition in WorkerThreadPool when Physics 2D or 3D is selected to run on a separate thread.
Diffstat (limited to 'core/object')
-rw-r--r--core/object/worker_thread_pool.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/object/worker_thread_pool.cpp b/core/object/worker_thread_pool.cpp
index 9b3dc6833e..0218a4c8f6 100644
--- a/core/object/worker_thread_pool.cpp
+++ b/core/object/worker_thread_pool.cpp
@@ -402,7 +402,9 @@ void WorkerThreadPool::wait_for_group_task_completion(GroupID p_group) {
}
}
- groups.erase(p_group); // Threads do not access this, so safe to erase here.
+ task_mutex.lock(); // This mutex is needed when Physics 2D and/or 3D is selected to run on a separate thread.
+ groups.erase(p_group);
+ task_mutex.unlock();
}
void WorkerThreadPool::init(int p_thread_count, bool p_use_native_threads_low_priority, float p_low_priority_task_ratio) {