Skip to content

Apply singleton instance binding clean-up fix no matter how it is created#1908

Open
dsnopek wants to merge 1 commit into
godotengine:masterfrom
dsnopek:engine-get-singleton-fix-squashed
Open

Apply singleton instance binding clean-up fix no matter how it is created#1908
dsnopek wants to merge 1 commit into
godotengine:masterfrom
dsnopek:engine-get-singleton-fix-squashed

Conversation

@dsnopek
Copy link
Copy Markdown
Collaborator

@dsnopek dsnopek commented Jan 23, 2026

Fixes #1900

This fix is a little weird in that it only addresses the Wrapped(GodotObject *) constructor, but I think that's actually correct, because we only want to do this when the instance binding creation was initiated on the engine side using a pre-existing instance. If someone creates a new instance of a singleton (which they really shouldn't do, but there's nothing preventing it) then it shouldn't register that as an engine singleton.

@dsnopek dsnopek added this to the 10.x milestone Jan 23, 2026
@dsnopek dsnopek requested a review from a team as a code owner January 23, 2026 15:29
@dsnopek dsnopek added bug This has been identified as a bug crash labels Jan 23, 2026
@Naros
Copy link
Copy Markdown
Contributor

Naros commented Jan 26, 2026

Hi @dsnopek so the game does not crash, but the Godot Editor (beta2) still crashes on exit. I am updating my local windows builds to rc2 with debug symbols and will report back.

================================================================
CrashHandlerException: Program crashed with signal 11
Engine version: Godot Engine v4.6.beta2.official (551ce8d47feda9c81c870314745366b24957624b)
Dumping the backtrace.
[1] error(-1): no debug info in PE/COFF executable
[2] error(-1): no debug info in PE/COFF executable
[3] error(-1): no debug info in PE/COFF executable
[4] error(-1): no debug info in PE/COFF executable
[5] error(-1): no debug info in PE/COFF executable
[6] error(-1): no debug info in PE/COFF executable
-- END OF C++ BACKTRACE --
================================================================

With rc2 debug symbols enabled

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.6.rc.custom_build (78c6632eb174aabb2790975cf83e28fee065b43d)
Dumping the backtrace.
[0] <couldn't map PC to fn name>
[1] <couldn't map PC to fn name>
[2] Object::~Object (E:\GitHub\godotengine2\core\object\object.cpp:2466)
[3] GDExtensionManager::`scalar deleting destructor'
[4] unregister_core_types (E:\GitHub\godotengine2\core\register_core_types.cpp:426)
[5] Main::cleanup (E:\GitHub\godotengine2\main\main.cpp:5252)
[6] widechar_main (E:\GitHub\godotengine2\platform\windows\godot_windows.cpp:105)
[7] _main (E:\GitHub\godotengine2\platform\windows\godot_windows.cpp:128)
[8] main (E:\GitHub\godotengine2\platform\windows\godot_windows.cpp:140)
[9] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[10] <couldn't map PC to fn name>
-- END OF C++ BACKTRACE --
================================================================

This includes the godot-cpp v10 patch from this PR

@Naros
Copy link
Copy Markdown
Contributor

Naros commented May 26, 2026

@dsnopek where does this stand?

@dsnopek
Copy link
Copy Markdown
Collaborator Author

dsnopek commented May 26, 2026

I haven't had a chance to come back to it.

I know I tested this when I made the PR, but other than the automated test this adds, I don't recall how I was doing that. But however I was testing it, it didn't crash for me like in your testing. Can you share an MRP that I can use?

@Naros
Copy link
Copy Markdown
Contributor

Naros commented May 27, 2026

Hi @dsnopek you can find a simple MRP:
https://github.com/Naros/godot-cpp-mrp

In the get-singleton-crash-windows branch, you can check that out, and compile it using scons and target editor:

git clone https://github.com/Naros/godot-cpp-mrp.git .
git checkout get-singleton-crash-windows
git submodule init
git submodule update
scons target=editor

Then load the sample project from ./project into the editor on Windows, making sure to start the editor from a terminal/cmd window, and then stop the editor. Upon stop you'll get the output:

OpenGL API 3.3.0 NVIDIA 591.86 - Compatibility - Using Device: NVIDIA - NVIDIA GeForce RTX 3080 Ti

Editing project: E:/GitHub/godot-cpp-mrp/project
Godot Engine v4.7.beta3.official.860821708 - https://godotengine.org
D3D12 12_0 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce RTX 3080 Ti


================================================================
CrashHandlerException: Program crashed with signal 11
Engine version: Godot Engine v4.7.beta3.official (86082170822e19ebb619c7f53c8fe54a6f8d3d2a)
Dumping the backtrace.
Load address: 7ff521b40000

[1] 7ff665c02321 (main+40c2321) - no debug info in PE/COFF executable
[2] 7ffd833e1732 (ntdll.dll+121732) - no debug info in PE/COFF executable
[3] 7ffd834263de (ntdll.dll+1663de) - no debug info in PE/COFF executable
[4] 7ffd832d9496 (ntdll.dll+19496) - no debug info in PE/COFF executable
[5] 7ffd83425d1d (ntdll.dll+165d1d) - no debug info in PE/COFF executable
[6] 7ffd010018ff (main+69f4c18ff) - no debug info in PE/COFF executable
-- END OF C++ BACKTRACE --
================================================================

If you remove the for loop in the MrpEditorPlugin::enter_tree() method, and recompile, and retest, the crash does not occur.

NOTE: The MRP is using master for godot-cpp and not this PR.

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

Labels

bug This has been identified as a bug crash

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor crashes on shutdown when fetching a singleton via Engine

2 participants