From 167b4c071c8bce92d2167c3ffda2d17fd02a4ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20W=C3=B6rner?= Date: Sun, 28 Jan 2024 11:46:38 +0100 Subject: [PATCH] Fixed ~CSharpScript() holding on to a mutex longer than necessary, creating potential for a deadlock. (cherry picked from commit 9d50a486bf00592888664828b35d703c46eaa9b0) --- modules/mono/csharp_script.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 8e1587997b9..b415ad6eca0 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2819,15 +2819,17 @@ CSharpScript::CSharpScript() { #ifdef DEBUG_ENABLED { MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex); - CSharpLanguage::get_singleton()->script_list.add(&this->script_list); + CSharpLanguage::get_singleton()->script_list.add(&script_list); } #endif } CSharpScript::~CSharpScript() { #ifdef DEBUG_ENABLED - MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex); - CSharpLanguage::get_singleton()->script_list.remove(&this->script_list); + { + MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex); + CSharpLanguage::get_singleton()->script_list.remove(&script_list); + } #endif if (GDMonoCache::godot_api_cache_updated) {