From 17e1edcf54baf82f1d102928c0bcdc85b1ab6959 Mon Sep 17 00:00:00 2001 From: myaaaaaaaaa <103326468+myaaaaaaaaa@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:56:54 -0500 Subject: [PATCH] Work around a race condition with ScriptServer during initialization --- core/os/thread.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 9d16392b2a53..82e2e2faabb5 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -58,13 +58,19 @@ void Thread::callback(Thread *p_self, const Settings &p_settings, Callback p_cal if (platform_functions.init) { platform_functions.init(); } - ScriptServer::thread_enter(); // Scripts may need to attach a stack. + + // Currently causes a race condition due to the fact that threads are + // spawned before ScriptServer is even initialized. + // This is currently unused since neither GDScript nor C# require + // attaching a stack to new threads, so we just disable for now. + + //ScriptServer::thread_enter(); if (platform_functions.wrapper) { platform_functions.wrapper(p_callback, p_userdata); } else { p_callback(p_userdata); } - ScriptServer::thread_exit(); + //ScriptServer::thread_exit(); if (platform_functions.term) { platform_functions.term(); }