godotengine/godot

The editor crashes after turning off a plugin and closing the current scene

Zylann opened this issue · 0 comments

Godot version

Godot 4.0.1

System information

Windows 10 64 bits NVIDIA GeForce GTX 1060

Issue description

The editor crashes without any information after turning off a GDScript plugin and then close the current scene.

I tried:

  • Using a debug build with the debug MSVC runtime (off by default)
  • Using a C++ debugger

But oddly enough, neither gave me any call stack. All I get is:

Exception thrown at 0x00007FF668765716 in godot.windows.editor.dev.x86_64.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
The program '[14300] godot.windows.editor.dev.x86_64.exe' has exited with code 1 (0x1).

However, I'm one of the few weirdos in the world who compiles debug builds with the Tracy profiler. I attached Tracy as well, and it turns out Tracy did catch something:
image

Which led me to add these prints:

void EditorNode::_plugin_over_edit(EditorPlugin *p_plugin, Object *p_object) {
	CRASH_COND(p_plugin == nullptr);
	print_line("EditorNode::_plugin_over_edit BEGIN");
	if (p_object) {
		print_line("EditorNode::_plugin_over_edit A");
		editor_plugins_over->add_plugin(p_plugin);
		print_line("EditorNode::_plugin_over_edit B");
		p_plugin->make_visible(true);
		print_line("EditorNode::_plugin_over_edit C");
		p_plugin->edit(p_object);
	} else {
		print_line("EditorNode::_plugin_over_edit D");
		editor_plugins_over->remove_plugin(p_plugin);
		print_line("EditorNode::_plugin_over_edit G");
		if (ObjectDB::get_instance(p_plugin->get_instance_id()) == nullptr) {
			print_line("p_plugin is garbage");
		}
		print_line("EditorNode::_plugin_over_edit E");
		p_plugin->make_visible(false);
		print_line("EditorNode::_plugin_over_edit F");
		p_plugin->edit(nullptr);
	}
	print_line("EditorNode::_plugin_over_edit END");
}

And surely enough, p_plugin is garbage occurs.

Steps to reproduce

In the provided reproduction project:

  • Enable the plugin
  • Open main.tscn
  • Select the Child node (the plugin _handles Node)
  • Turn off the plugin
  • Close the scene

If it does not reproduce for you, keep trying, or use the prints I added in C++ to highlight the problem.

Minimal reproduction project

TurnOffPluginCrash.zip