Skip to content

Fix Editor crash during first scan in headless import mode. #108992

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

Merged
merged 1 commit into from
Jul 27, 2025

Conversation

WhalesState
Copy link
Contributor

@WhalesState WhalesState commented Jul 26, 2025

It works the same in headless import mode w/o --quit.
but without --import, when using --quit it aborts before loading the editor layout.

[   0% ] first_scan_filesystem | Started Project initialization (5 steps)
[   0% ] first_scan_filesystem | Scanning file structure...
[  16% ] first_scan_filesystem | Loading global class names...
[  33% ] first_scan_filesystem | Verifying GDExtensions...
[  50% ] first_scan_filesystem | Creating autoload scripts...
[  66% ] first_scan_filesystem | Initializing plugins...
[  83% ] first_scan_filesystem | Starting file scan...
[ DONE ] first_scan_filesystem

[   0% ] loading_editor_layout | Started Loading editor (5 steps)
[   0% ] loading_editor_layout | Loading editor layout...
[  16% ] loading_editor_layout | Loading docks...
[  33% ] loading_editor_layout | Reopening scenes...
Hello from my autoload!
[  50% ] loading_editor_layout | Loading central editor layout...
[  66% ] loading_editor_layout | Loading plugin window layout...
[  83% ] loading_editor_layout | Editor layout ready.
[ DONE ] loading_editor_layout

@WhalesState WhalesState requested a review from a team as a code owner July 26, 2025 11:07
@WhalesState WhalesState requested a review from a team as a code owner July 26, 2025 11:36
@WhalesState WhalesState force-pushed the headless-import branch 2 times, most recently from 6299f26 to 79e68d8 Compare July 26, 2025 11:51
@Repiteo Repiteo added this to the 4.5 milestone Jul 26, 2025
@Repiteo
Copy link
Contributor

Repiteo commented Jul 26, 2025

Looks like a non-headless --editor --quit caused some kind of error in the GHA

@WhalesState
Copy link
Contributor Author

WhalesState commented Jul 26, 2025

Looks like a non-headless --editor --quit caused some kind of error in the GHA

Tracking it now.

    #0 0x00001d7cf988 in Node::is_part_of_edited_scene() const scene/main/node.cpp:2702
    #1 0x00001d772b8e in Node::_notification(int) scene/main/node.cpp:182
    #2 0x00001234ad68 in Node::_notification_backwardv(int) scene/main/node.h:48
    #3 0x00001791f17b in EditorNode::_notification_backwardv(int) editor/editor_node.h:118
    #4 0x00002853ba26 in Object::_notification_backward(int) core/object/object.cpp:965
    #5 0x00000ff6e7ba in Object::notification(int, bool) core/object/object.h:888
    #6 0x00001d77deec in Node::_propagate_exit_tree() scene/main/node.cpp:412
    #7 0x00001d77d930 in Node::_propagate_exit_tree() scene/main/node.cpp:403
    #8 0x00001d7e38d8 in Node::_set_tree(SceneTree*) scene/main/node.cpp:3304
    #9 0x00001d94869d in SceneTree::finalize() scene/main/scene_tree.cpp:839
    #10 0x00000ff8d549 in OS_LinuxBSD::run() platform/linuxbsd/os_linuxbsd.cpp:994
    #11 0x00000ff6ae5e in main platform/linuxbsd/godot_linuxbsd.cpp:85

if (data.tree->is_accessibility_supported() && !is_part_of_edited_scene()) this check is called during exiting tree.

from SceneTree::finalize() -> root->_set_tree(nullptr);

		case NOTIFICATION_EXIT_TREE: {
			ERR_FAIL_NULL(get_viewport());
			ERR_FAIL_NULL(data.tree);

			if (data.tree->is_accessibility_supported() && !is_part_of_edited_scene()) {
				if (data.accessibility_element.is_valid()) {
					DisplayServer::get_singleton()->accessibility_free_element(data.accessibility_element);
					data.accessibility_element = RID();
				}
				data.tree->_accessibility_notify_change(this, true);
				if (data.parent) {
					data.tree->_accessibility_notify_change(data.parent);
				} else {
					data.tree->_accessibility_notify_change(get_window()); // Root node.
				}
			}

running with --rendering-driver opengl3 --audio-driver Dummy -e --quit --path /home/fedora/Downloads/regression-test-project-4.0

The issue ==161461==ERROR: AddressSanitizer: heap-use-after-free comes from here.

bool Node::is_part_of_edited_scene() const {
	return Engine::get_singleton()->is_editor_hint() && is_inside_tree() && data.tree->get_edited_scene_root() &&
			data.tree->get_edited_scene_root()->get_parent()->is_ancestor_of(this);
}

@WhalesState
Copy link
Contributor Author

WhalesState commented Jul 27, 2025

get_parent() was called on a deleted object pointer after calling EditorData::clear_edited_scenes() without setting SceneTree::edited_scene_root to nullptr.

Also we may need to add this run to godot-project-test actions to avoid breaking the headless import again.

    - name: Import headless project
      shell: sh
      run: |
        xvfb-run ${{ inputs.bin }} --audio-driver Dummy --headless --editor --import --path test_project 2>&1 | tee sanitizers_log.txt || true
        misc/scripts/check_ci_log.py sanitizers_log.txt

Sorry about being late fixing this, it required me to build the editor with the same flags and track the issue without VSCode debugging tools because the crash wasn't telling which is the deleted object.

@Repiteo
Copy link
Contributor

Repiteo commented Jul 27, 2025

--import implies --editor --quit, and the actions should be using that instead of the legacy equivalent. That can be handled in a separate PR though. Great job getting to the root of the issue!

@WhalesState
Copy link
Contributor Author

Thank you!

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

Seems to work fine, although if it causes another major regression we should consider reverting the original fix until 4.6.

@Repiteo Repiteo merged commit 1a6da7b into godotengine:master Jul 27, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jul 27, 2025

Thanks!

@WhalesState WhalesState deleted the headless-import branch July 27, 2025 16:20
Handagotes pushed a commit to Handagotes/godot that referenced this pull request Jul 30, 2025
Fix Editor crash during first scan in headless import mode.
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.

Projects with autoloads crash during headless import
3 participants