From cfa7e72057c7728e01fbf3f492b28174c06f9e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Mon, 27 Nov 2023 13:01:37 +0100 Subject: [PATCH] Fix GDScript thread-exit routine assuming thread-enter was called --- modules/gdscript/gdscript.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 05c25584177..87f21bf5689 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2106,6 +2106,12 @@ void GDScriptLanguage::thread_enter() { } void GDScriptLanguage::thread_exit() { + // This thread may have been created before GDScript was up + // (which also means it can't have run any GDScript code at all). + if (!GDScript::func_ptrs_to_update_thread_local) { + return; + } + GDScript::_fixup_thread_function_bookkeeping(); bool destroy = false;