Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix language server causing random crashes when use_threads is enabled #99861

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ryan-000
Copy link
Contributor

For a few years, I’ve been experiencing random crashes in VS Code when saving GDScript files, and after a long time troubleshooting, I finally found the root cause.

The issue was that ScriptEditor::reload_scripts was being called directly on the language server thread when network/language_server/use_thread was enabled. This led to race conditions that would eventually cause the crashes.

@Ryan-000 Ryan-000 force-pushed the Fix-language-server-thread-crash branch from 1aaab5a to 3439575 Compare November 30, 2024 22:07
@@ -49,6 +50,7 @@ class GDScriptTextDocument : public RefCounted {
void willSaveWaitUntil(const Variant &p_param);
void didSave(const Variant &p_param);

void reload_script(Ref<GDScript> to_reload_script);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void reload_script(Ref<GDScript> to_reload_script);
void reload_script(Ref<GDScript> p_to_reload_script);

Prefix arguments with p_

@@ -35,6 +35,7 @@

#include "core/io/file_access.h"
#include "core/object/ref_counted.h"
#include "modules/gdscript/gdscript.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "modules/gdscript/gdscript.h"
class GDScript;

Forward declare this

}
}

void GDScriptTextDocument::reload_script(Ref<GDScript> to_reload_script) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void GDScriptTextDocument::reload_script(Ref<GDScript> to_reload_script) {
void GDScriptTextDocument::reload_script(Ref<GDScript> p_to_reload_script) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants