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 if tool script deletes the scene root #99001

Closed
ultsi opened this issue Nov 9, 2024 · 4 comments
Closed

Editor crashes if tool script deletes the scene root #99001

ultsi opened this issue Nov 9, 2024 · 4 comments
Labels

Comments

@ultsi
Copy link

ultsi commented Nov 9, 2024

Tested versions

  • Reproducible in 4.3
  • Reproducible also in newest 4.4 master, custom build

System information

Godot v4.3.dev3 - Ubuntu 20.04.6 LTS (Focal Fossa) - X11 - Vulkan (Mobile) - dedicated AMD Radeon RX 6600 (RADV NAVI23) () - AMD Ryzen 7 5800X 8-Core Processor (16 Threads)

Issue description

Editor crashes if a scene root deletes itself via tool script

Backtrace below. I tried to turn debug symbols on by compiling with production=yes debug_symbols=yes, but didn't get any extra info in this case:

handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.4.dev.custom_build (db05f1dd8441be7fe6dd83097b0732722b0cc1c3)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x43090) [0x7fa7a4fb8090] (??:0)
[2] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0x65b730) [0x564959d5b730] (/home/ultsi/dev/godot/godot-src/core/string/ustring.cpp:4158)
[3] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0xc326a2) [0x56495a3326a2] (/home/ultsi/dev/godot/godot-src/core/string/ustring.cpp:4219)
[4] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0x39afef9) [0x56495d0afef9] (/home/ultsi/dev/godot/godot-src/editor/gui/scene_tree_editor.cpp:337)
[5] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0x39b2c99) [0x56495d0b2c99] (/home/ultsi/dev/godot/godot-src/editor/gui/scene_tree_editor.cpp:653)
[6] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0x3a6c861) [0x56495d16c861] (/home/ultsi/dev/godot/godot-src/./core/variant/binder_common.h:304)
[7] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0xf06525) [0x56495a606525] (/home/ultsi/dev/godot/godot-src/core/variant/callable.cpp:57)
[8] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0x654721) [0x564959d54721] (/home/ultsi/dev/godot/godot-src/core/object/message_queue.cpp:221)
[9] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0xcce948) [0x56495a3ce948] (/home/ultsi/dev/godot/godot-src/core/object/message_queue.cpp:268)
[10] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0x523ca5f) [0x56495e93ca5f] (/home/ultsi/dev/godot/godot-src/servers/physics_server_3d.cpp:94 (discriminator 2))
[11] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0x525ae4a) [0x56495e95ae4a] (/home/ultsi/dev/godot/godot-src/platform/linuxbsd/os_linuxbsd.cpp:962)
[12] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0x623f42) [0x564959d23f42] (/home/ultsi/dev/godot/godot-src/platform/linuxbsd/godot_linuxbsd.cpp:85)
[13] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fa7a4f99083] (??:0)
[14] /home/ultsi/dev/godot/godot-src/bin/godot.linuxbsd.editor.x86_64(+0x6265ce) [0x564959d265ce] (??:?)
-- END OF BACKTRACE --

Steps to reproduce

  1. Create and save a scene
  2. Add a tool script to the root
  3. call queue_free in _physics_process
  4. Editor crashes when trying to open the scene

Minimal reproduction project (MRP)

tool-script-crash.zip

@ryevdokimov
Copy link
Contributor

See: #90176

If you're interested in a PR that allows you to do this see: #93726

@ultsi
Copy link
Author

ultsi commented Nov 10, 2024

I read through the closed issue, and I still think this is a valid issue for normal users. In my case I created a scene resembling a bullet, tested with @tool mode that its velocity is set correctly via export variables etc. in the editor. Then while running the game I created the behavior where the bullet deletes itself after it is a long distance away from its starting point.

Because I wrote the auto delete behavior in game with hot reload, the editor didn't crash instantly after adding queue_free(). Only the next day, when I came back and started to edit the bullet scene in the editor, the editor started crashing without any obvious reason. Took me an hour to debug the issue.

I think a fix could be that queue_free() throws an error, if it is being used from a tool script, and if it is freeing the scene root.

OR the editor could crash, but have a message pop up about this.

@ultsi
Copy link
Author

ultsi commented Nov 10, 2024

Ah older issues describe that this is something user needs to be aware of: #26409

Maintainers: you can close this if you think the same still.

@akien-mga
Copy link
Member

Yeah this is sadly a case of "With great power comes great responsibility". Tool scripts are super powerful but that also implies the power of wreaking havoc in the editor and causing crashes.

We're working on a Safe Mode feature which will at least let you recover such crashed projects in a better way (tested with the MRP, it makes it possible to open the project and fix the tool script): #92563.

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

No branches or pull requests

3 participants