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

Editor crashes and leaks RIDs when you open and close a custom theme preview tab #81085

Closed
YuriSizov opened this issue Aug 28, 2023 · 3 comments · Fixed by #82442
Closed

Editor crashes and leaks RIDs when you open and close a custom theme preview tab #81085

YuriSizov opened this issue Aug 28, 2023 · 3 comments · Fixed by #82442

Comments

@YuriSizov
Copy link
Contributor

YuriSizov commented Aug 28, 2023

Godot version

master (541674d), 4.2.dev3, 4.1.stable, 4.0.3.stable

System information

Godot v4.2.dev (541674d) - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3070 Ti Laptop GPU (NVIDIA; 31.0.15.3699) - 12th Gen Intel(R) Core(TM) i7-12700H (20 Threads)

Issue description

A crash with a leak happens on editor exit if you use custom theme previews in the theme editor. Using the theme editor normally with the default preview doesn't produce a crash. Opening a custom preview tab doesn't cause a crash either.

However, opening a custom preview tab and then closing it will cause a leak and a crash on exit. There are no immediate errors when you close the tab and everything appears to be working normally.

Leaks are reported like so:

ERROR: 4 RID allocations of type 'struct RendererRD::LightStorage::ShadowAtlas' were leaked at exit.
ERROR: 4 RID allocations of type 'struct RendererRD::TextureStorage::RenderTarget' were leaked at exit.
ERROR: 87 RID allocations of type 'class RendererRD::TextureStorage::Texture' were leaked at exit.
ERROR: 50 RID allocations of type 'struct RendererCanvasCull::Item' were leaked at exit.

The crash happens as we're trying to free various rendering structs:

godot.windows.editor.dev.x86_64.exe!RendererCanvasRender::Polygon::~Polygon() Line 154 (c:\Projects\godot-engine\master\servers\rendering\renderer_canvas_render.h:154)
godot.windows.editor.dev.x86_64.exe!RendererCanvasRender::Item::CommandPolygon::~CommandPolygon() (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!RendererCanvasRender::Item::CommandPolygon::`scalar deleting destructor'(unsigned int) (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!memdelete<RendererCanvasRender::Item::Command>(RendererCanvasRender::Item::Command * p_class) Line 112 (c:\Projects\godot-engine\master\core\os\memory.h:112)
godot.windows.editor.dev.x86_64.exe!RendererCanvasRender::Item::clear() Line 417 (c:\Projects\godot-engine\master\servers\rendering\renderer_canvas_render.h:417)
godot.windows.editor.dev.x86_64.exe!RendererCanvasRender::Item::~Item() Line 470 (c:\Projects\godot-engine\master\servers\rendering\renderer_canvas_render.h:470)
godot.windows.editor.dev.x86_64.exe!RendererCanvasCull::Item::~Item() (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!RendererCanvasCull::Item::`scalar deleting destructor'(unsigned int) (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!RID_Alloc<RendererCanvasCull::Item,1>::~RID_Alloc<RendererCanvasCull::Item,1>() Line 349 (c:\Projects\godot-engine\master\core\templates\rid_owner.h:349)
godot.windows.editor.dev.x86_64.exe!RID_Owner<RendererCanvasCull::Item,1>::~RID_Owner<RendererCanvasCull::Item,1>() (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!RendererCanvasCull::~RendererCanvasCull() Line 2163 (c:\Projects\godot-engine\master\servers\rendering\renderer_canvas_cull.cpp:2163)
godot.windows.editor.dev.x86_64.exe!RendererCanvasCull::`scalar deleting destructor'(unsigned int) (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!memdelete<RendererCanvasCull>(RendererCanvasCull * p_class) Line 112 (c:\Projects\godot-engine\master\core\os\memory.h:112)
godot.windows.editor.dev.x86_64.exe!RenderingServerDefault::~RenderingServerDefault() Line 430 (c:\Projects\godot-engine\master\servers\rendering\rendering_server_default.cpp:430)
godot.windows.editor.dev.x86_64.exe!RenderingServerDefault::`scalar deleting destructor'(unsigned int) (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!memdelete<RenderingServer>(RenderingServer * p_class) Line 112 (c:\Projects\godot-engine\master\core\os\memory.h:112)
godot.windows.editor.dev.x86_64.exe!finalize_display() Line 318 (c:\Projects\godot-engine\master\main\main.cpp:318)
godot.windows.editor.dev.x86_64.exe!Main::cleanup(bool p_force) Line 3707 (c:\Projects\godot-engine\master\main\main.cpp:3707)
godot.windows.editor.dev.x86_64.exe!widechar_main(int argc, wchar_t * * argv) Line 184 (c:\Projects\godot-engine\master\platform\windows\godot_windows.cpp:184)
godot.windows.editor.dev.x86_64.exe!_main() Line 204 (c:\Projects\godot-engine\master\platform\windows\godot_windows.cpp:204)

I assume that the leak and the crash are related. So without rebuilding from source I've tested various previous official releases, and I can reproduce the leak in all previous 4.2 dev snapshots, in 4.1.stable and in 4.0.3.stable.

ERROR: 4 RID allocations of type 'N10RendererRD12LightStorage11ShadowAtlasE' were leaked at exit.
ERROR: 4 RID allocations of type 'N10RendererRD14TextureStorage12RenderTargetE' were leaked at exit.
ERROR: 87 RID allocations of type 'N10RendererRD14TextureStorage7TextureE' were leaked at exit.
ERROR: 50 RID allocations of type 'N18RendererCanvasCull4ItemE' were leaked at exit.

Steps to reproduce

Open any project and create a GUI scene and an empty Theme resource.
Open the resource for editing and in the theme editor click on "Add Preview", select the GUI scene.
Close the newly opened tab and exit the editor.
If you have a debugger attached, you should catch a crash, if you have a terminal open, you should see the leak.

Minimal reproduction project

N/a

@YuriSizov
Copy link
Contributor Author

I should clarify, that closing the editor with the second tab open does not lead to any issues. This is only reproduceable for me if you manually close the tab before exiting.

@KoBeWi
Copy link
Member

KoBeWi commented Sep 13, 2023

I just noticed I have the same crash in my random test project for an addon:
Godot-Quick-Scenes.zip
Just open it and close. No themes editor used.
I experienced the same crash in other projects too. This also makes it impossible to use the "Reload Current Project" option.

@YuriSizov
Copy link
Contributor Author

YuriSizov commented Sep 27, 2023

@KoBeWi You free the dock, but not the button.

func _exit_tree():
	remove_control_from_bottom_panel(dock)
	remove_control_from_container(CONTAINER_TOOLBAR, button)
	dock.free()

And my crash is of a similar nature 🤦 Not sure how I've missed it before.

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

Successfully merging a pull request may close this issue.

3 participants