fix: use update_file() instead of full scan() on single-file writes (prevents EditorFileSystem global-class SIGABRT)#508
Merged
Conversation
script_create, script_patch, and filesystem write_text each triggered a full recursive EditorInterface.get_resource_filesystem().scan() per write. Under concurrent file creation (e.g. multiple MCP clients, or a stress run) these scans stack: the editor re-enqueues the update_scripts_classes / update_script_paths_documentation WorkerThreadPool tasks while a previous scan is still pending, emitting "Task '...' already exists" / Condition "!tasks.has(p_task)" is true, and the global-class registry is left inconsistent. The next idle filesystem scan can then SIGABRT in ScriptServer::remove_global_class_by_path() — a hard editor crash. Switch all three sites to EditorFileSystem.update_file(path), the single-file registration call the rest of the plugin already uses (material/theme handlers, filesystem reimport, resource_io). It registers just the written file without the recursive scan-action batch, so the duplicate-task race can't occur. Validated with a concurrency stress harness: - before (full scan): 5x "Task ... already exists" + 5x "!tasks.has(p_task)" per run, intermittently escalating to the SIGABRT (3 crash reports). - after (update_file): 0 of those engine errors across heavier runs, no crash. - create -> immediate attach still settles (import_settled=true), so the #261 import-settle behaviour is preserved. - GDScript script (38) + filesystem (16) suites pass; Python import-settle (6) + script/filesystem unit tests (67) pass. Engine-side record of the underlying abort: dsarno/godot#6. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
script_create,script_patch, and filesystemwrite_texteach triggered a full recursiveEditorInterface.get_resource_filesystem().scan()per write. Under concurrent file creation (multiple MCP clients, or a stress run), these scans stack — the editor re-enqueues theupdate_scripts_classes/update_script_paths_documentationWorkerThreadPool tasks while a previous scan is still pending:…leaving the global-class registry inconsistent. The next idle filesystem scan can then SIGABRT in
ScriptServer::remove_global_class_by_path()— a hard editor crash:Engine-side record of the underlying abort:
dsarno/godot#6.Fix
Switch all three sites to
EditorFileSystem.update_file(path)— the single-file registration call the rest of the plugin already uses (material/theme handlers, filesystemreimport,resource_io). It registers just the written file without the recursive scan-action batch, so the duplicate-task race can't occur. It's also cheaper than a full project rescan per write.Validation (concurrency stress harness)
scan()(before)update_file()(after)Task ... already exists/!tasks.has(p_task)create→ immediateattachstill settles (import_settled=true) — Harden script_create -> script_attach against Godot import races #261 import-settle behaviour preserved.script(38) +filesystem(16) suites pass; Python import-settle (6) + script/filesystem unit tests (67) pass.🤖 Generated with Claude Code