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

Segfault when exiting editor with a scene containing a pcam #389

Open
imberny opened this issue Sep 19, 2024 · 5 comments
Open

Segfault when exiting editor with a scene containing a pcam #389

imberny opened this issue Sep 19, 2024 · 5 comments

Comments

@imberny
Copy link

imberny commented Sep 19, 2024

Issue description

Godot Engine v4.3.stable.arch_linux

Quitting the Godot editor with an open scene containing a pcam results in a segmentation fault.

It seems like the PhantomCameraManager node is freed before the in-editor phantom cameras. Them accessing the manager in their _exit_tree method is what seems to trigger the segfault.

Steps to reproduce

The MRP is a blank project containing only the phantom camera addon.

  • open one of the example scenes from the addon
  • quit the editor
  • segfault

(Optional) Minimal reproduction project

segfault.zip

@ramokz
Copy link
Owner

ramokz commented Oct 9, 2024

Strange, can't spot any errors when quitting the editor — using the same Godot editor (v4.3.stable.arch_linux).

Might be due to different desktop environments?
Which one do you use and, more importantly, where do you see the error?

@imberny
Copy link
Author

imberny commented Oct 10, 2024

Manjaro linux. I'm getting the error in the console. I'm launching the editor directly via > godot -e .

To confirm, I built godot from source and debugged the editor. The issue was in the _exit_tree method of phantom_camera_host.gd and phantom_camera_2d/3d.gd. In-editor cameras (running as a tool script) would fail when trying to reference _phantom_camera_manager. I'm not sure how godot's editor shutdown works and why it works fine in game, but when those editor nodes exit the tree the _phantom_camera_manager singleton node is invalid, resulting in a null reference which causes a segfault for me.

I added a simple is_instance_valid(_phantom_camera_manager) check and that prevented segfaults.

It's not a big issue, but it just made the process of restarting the editor tedious.

Want me to make a pull request?

@ramokz
Copy link
Owner

ramokz commented Oct 15, 2024

Hmm, odd, I'm not getting any errors when following the repro steps in both 0.7.3 and 0.8 Beta. Have posted the terminal log below.

What does your error log look like?

❯ godot -e .
Godot Engine v4.3.stable.arch_linux - https://godotengine.org
Invalid value (0) for DRI_PRIME. Should be > 0
Inconsistent value (1) for DRI_PRIME. Should be < 1 (GPU devices count). Using: 0
Inconsistent value (2) for DRI_PRIME. Should be < 1 (GPU devices count). Using: 0
Inconsistent value (3) for DRI_PRIME. Should be < 1 (GPU devices count). Using: 0
OpenGL API 4.6 (Core Profile) Mesa 24.2.4-arch1.1 - Compatibility - Using Device: AMD - AMD Radeon RX 5700 XT (radeonsi, navi10, LLVM 18.1.8, DRM 3.59, 6.11.3-arch1-1)

Editing project: /home/marcus/Downloads/segfault-investigation
Godot Engine v4.3.stable.arch_linux - https://godotengine.org
Vulkan 1.3.289 - Forward+ - Using Device #0: AMD - AMD Radeon RX 5700 XT (RADV NAVI10)

~ took 5s 
➜ 
Godot Engine v4.3.stable.arch_linux - https://godotengine.org
Vulkan 1.3.289 - Forward+ - Using Device #0: AMD - AMD Radeon RX 5700 XT (RADV NAVI10)


================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.stable.arch_linux
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x3d1d0) [0x73cbf135d1d0] (??:0)
[2] /usr/bin/godot(+0x4221873) [0x5eedebd70873] (??:?)
[3] /usr/bin/godot(+0x4e5f79) [0x5eede8034f79] (??:?)
[4] /usr/bin/godot(+0x2fc8c7) [0x5eede7e4b8c7] (??:?)
[5] /usr/bin/godot(+0x21d4fc1) [0x5eede9d23fc1] (??:?)
[6] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[7] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[8] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[9] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[10] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[11] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[12] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[13] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[14] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[15] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[16] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[17] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[18] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[19] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[20] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[21] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[22] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[23] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[24] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[25] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[26] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[27] /usr/bin/godot(+0x21d4f3e) [0x5eede9d23f3e] (??:?)
[28] /usr/bin/godot(+0x222add9) [0x5eede9d79dd9] (??:?)
[29] /usr/bin/godot(+0x22582e4) [0x5eede9da72e4] (??:?)
[30] /usr/bin/godot(+0x97dbe) [0x5eede7be6dbe] (??:?)
[31] /usr/lib/libc.so.6(+0x25e08) [0x73cbf1345e08] (??:0)
[32] /usr/lib/libc.so.6(__libc_start_main+0x8c) [0x73cbf1345ecc] (??:0)
[33] /usr/bin/godot(+0xb7c35) [0x5eede7c06c35] (??:?)
-- END OF BACKTRACE --
================================================================

@imberny
Copy link
Author

imberny commented Oct 15, 2024

You seem the be reproducing the issue just fine. This is what I get launching the mrp using Godot 4.3. I just open the editor and quit normally.

❯ ../../Godot_v4.3-stable_linux.x86_64 -e .
Godot Engine v4.3.stable.official.77dcf97d8 - https://godotengine.org
Vulkan 1.3.277 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce GTX 1050


================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.stable.official (77dcf97d82cbfe4e4615475fa52ca03da645dbd8)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x3d1d0) [0x7f151999f1d0] (??:0)
[2] ../../Godot_v4.3-stable_linux.x86_64() [0x4113ecb] (??:0)
[3] ../../Godot_v4.3-stable_linux.x86_64() [0x7d7abe] (??:0)
[4] ../../Godot_v4.3-stable_linux.x86_64() [0x68756c] (??:0)
[5] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba5f] (??:0)
[6] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[7] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[8] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[9] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[10] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[11] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[12] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[13] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[14] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[15] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[16] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[17] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[18] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[19] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[20] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[21] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[22] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[23] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[24] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[25] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[26] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[27] ../../Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[28] ../../Godot_v4.3-stable_linux.x86_64() [0x232c8b3] (??:0)
[29] ../../Godot_v4.3-stable_linux.x86_64() [0x23b5028] (??:0)
[30] ../../Godot_v4.3-stable_linux.x86_64() [0x4202b7] (??:0)
[31] /usr/lib/libc.so.6(+0x25e08) [0x7f1519987e08] (??:0)
[32] /usr/lib/libc.so.6(__libc_start_main+0x8c) [0x7f1519987ecc] (??:0)
[33] ../../Godot_v4.3-stable_linux.x86_64() [0x43d44a] (??:0)
-- END OF BACKTRACE --
================================================================
zsh: IOT instruction (core dumped)  ../../Godot_v4.3-stable_linux.x86_64 -e .

And running it from my debug build of Godot 4.3:

❯ ../../src/bin/godot.linuxbsd.editor.x86_64 -V -e .
Godot Engine v4.3.1.rc.custom_build.6699ae789 (2024-09-17 18:47:01 UTC) - https://godotengine.org
Vulkan 1.3.277 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce GTX 1050


================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.1.rc.custom_build (6699ae7897658e44efc3cfb2cba91c11a8f5aa6a)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x3d1d0) [0x7f3e89ec11d0] (??:0)
[2] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x464eec2) [0x56064dcc5ec2] (/mnt/data/dev/godot/src/core/variant/variant_call.cpp:1211 (discriminator 1))
[3] ../../src/bin/godot.linuxbsd.editor.x86_64(+0xf35269) [0x56064a5ac269] (/mnt/data/dev/godot/src/./core/variant/variant.h:308)
[4] ../../src/bin/godot.linuxbsd.editor.x86_64(+0xe2bcd0) [0x56064a4a2cd0] (/mnt/data/dev/godot/src/modules/gdscript/gdscript.cpp:2032 (discriminator 1))
[5] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292eeb6) [0x56064bfa5eb6] (/mnt/data/dev/godot/src/./core/variant/variant.h:308)
[6] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[7] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[8] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[9] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[10] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[11] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[12] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[13] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[14] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[15] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[16] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[17] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[18] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[19] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[20] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[21] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[22] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[23] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[24] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[25] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[26] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[27] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292ee45) [0x56064bfa5e45] (/mnt/data/dev/godot/src/./core/templates/hash_map.h:462)
[28] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x292f53f) [0x56064bfa653f] (/mnt/data/dev/godot/src/scene/main/node.cpp:3167)
[29] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x29783ec) [0x56064bfef3ec] (/mnt/data/dev/godot/src/scene/main/scene_tree.cpp:643)
[30] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x610336) [0x560649c87336] (/mnt/data/dev/godot/src/platform/linuxbsd/os_linuxbsd.cpp:968)
[31] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x60e43e) [0x560649c8543e] (/mnt/data/dev/godot/src/platform/linuxbsd/godot_linuxbsd.cpp:89)
[32] /usr/lib/libc.so.6(+0x25e08) [0x7f3e89ea9e08] (??:0)
[33] /usr/lib/libc.so.6(__libc_start_main+0x8c) [0x7f3e89ea9ecc] (??:0)
[34] ../../src/bin/godot.linuxbsd.editor.x86_64(+0x60e235) [0x560649c85235] (??:?)
-- END OF BACKTRACE --
================================================================
zsh: IOT instruction (core dumped)  ../../src/bin/godot.linuxbsd.editor.x86_64 -V -e .

Debugging the 4.3 editor, it breaks here:

image

It's trying to call p_cam_removed on what I gather is an invalid reference. I'm not well versed enough in Godot's source files to understand much more.

@ramokz
Copy link
Owner

ramokz commented Oct 16, 2024

I can see what you mean. So yes, feel free to make a PR for it.

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

No branches or pull requests

2 participants