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

Project crashes after starting because breakpoint #92579

Open
ydeltastar opened this issue May 31, 2024 · 2 comments
Open

Project crashes after starting because breakpoint #92579

ydeltastar opened this issue May 31, 2024 · 2 comments

Comments

@ydeltastar
Copy link
Contributor

ydeltastar commented May 31, 2024

Tested versions

v4.3.beta.custom_build [6084499]

System information

Windows 11

Issue description

Breakpoints make my project crash a few seconds after running from the editor. It works if I remove them all or set it after the project is already running. The number and place of the breakpoints don't seem to matter.

The project starts and runs for about two seconds. The "Saving Scene" dialogue is 100% but still open in the editor. After this popup closes, the project keeps running for a few seconds but then silently crashes, probably when it tries to attach the debugger.

Log:

Godot Engine v4.3.beta.custom_build.60844997b (2024-05-30 09:48:18 UTC) - https://godotengine.org
WARNING: GENERAL - Message Id Number: 0 | Message Id Name: Loader Message
        windows_read_data_files_in_registry: Registry lookup failed to get layer manifest files.
        Objects - 1
                Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 2792596287088
     at: RenderingContextDriverVulkan::_debug_messenger_callback (drivers\vulkan\rendering_context_driver_vulkan.cpp:30)
Vulkan 1.3.260 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce RTX 3070

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.3.beta.custom_build (60844997bb2981c44e3b4396ab2918df90f13c97)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] <couldn't map PC to fn name>
[1] _CxxThrowException (D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\throw.cpp:75)
[2] __RTDynamicCast (D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\rtti.cpp:291)
[3] Object::cast_to<GDScriptNativeClass> (C:\godot\godot\core\object\object.h:805)
[4] GDScriptLanguage::debug_get_globals (C:\godot\godot\modules\gdscript\gdscript_editor.cpp:406)
[5] RemoteDebugger::debug (C:\godot\godot\core\debugger\remote_debugger.cpp:506)
[6] ScriptDebugger::debug (C:\godot\godot\core\debugger\script_debugger.cpp:86)
[7] GDScriptLanguage::debug_break (C:\godot\godot\modules\gdscript\gdscript_editor.cpp:272)
[8] GDScriptFunction::call (C:\godot\godot\modules\gdscript\gdscript_vm.cpp:3599)
[9] GDScriptInstance::callp (C:\godot\godot\modules\gdscript\gdscript.cpp:2050)
[10] Object::callp (C:\godot\godot\core\object\object.cpp:819)
[11] Variant::callp (C:\godot\godot\core\variant\variant_call.cpp:1211)
[12] GDScriptFunction::call (C:\godot\godot\modules\gdscript\gdscript_vm.cpp:1739)
[13] GDScriptInstance::callp (C:\godot\godot\modules\gdscript\gdscript.cpp:2050)
[14] Object::callp (C:\godot\godot\core\object\object.cpp:819)
[15] Variant::callp (C:\godot\godot\core\variant\variant_call.cpp:1211)
[16] GDScriptFunction::call (C:\godot\godot\modules\gdscript\gdscript_vm.cpp:1768)
[17] GDScriptInstance::callp (C:\godot\godot\modules\gdscript\gdscript.cpp:2050)
[18] Node::_gdvirtual__physics_process_call<0> (C:\godot\godot\scene\main\node.h:352)
[19] Node::_notification (C:\godot\godot\scene\main\node.cpp:60)
[20] Node::_notificationv (C:\godot\godot\scene\main\node.h:50)
[21] Object::notification (C:\godot\godot\core\object\object.cpp:906)
[22] SceneTree::_process_group (C:\godot\godot\scene\main\scene_tree.cpp:957)
[23] SceneTree::_process (C:\godot\godot\scene\main\scene_tree.cpp:1042)
[24] SceneTree::physics_process (C:\godot\godot\scene\main\scene_tree.cpp:491)
[25] Main::iteration (C:\godot\godot\main\main.cpp:4016)
[26] OS_Windows::run (C:\godot\godot\platform\windows\os_windows.cpp:1686)
[27] widechar_main (C:\godot\godot\platform\windows\godot_windows.cpp:181)
[28] _main (C:\godot\godot\platform\windows\godot_windows.cpp:206)
[29] main (C:\godot\godot\platform\windows\godot_windows.cpp:220)
[30] WinMain (C:\godot\godot\platform\windows\godot_windows.cpp:234)
[31] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[32] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================

Steps to reproduce

Not sure. Anywhere I put a breakpoint makes it crash.

Minimal reproduction project (MRP)

I can reproduce it every time in my project but I was unable to get a minimal example to do the same.

@ydeltastar ydeltastar changed the title Project crash after starting because breakpoint Project crashes after starting because breakpoint May 31, 2024
@ydeltastar
Copy link
Contributor Author

ydeltastar commented May 31, 2024

I found the cause. It happens when an autoload is deleted at startup like this:

var _free_on_start = true

func _enter_tree() -> void:
	if _free_on_start:
		queue_free()

Godot adds the autoload to the script server globals at startup but when the debugger checks these globals, the autoload object is invalid.

godot/main/main.cpp

Lines 3605 to 3614 in 705b7a0

//first pass, add the constants so they exist before any script is loaded
for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) {
const ProjectSettings::AutoloadInfo &info = E.value;
if (info.is_singleton) {
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptServer::get_language(i)->add_global_constant(info.name, Variant());
}
}
}

const Variant &var = gl_array[E.value];
if (Object *obj = var) {
if (Object::cast_to<GDScriptNativeClass>(obj)) {
continue;
}
}

@AThousandShips
Copy link
Member

You shouldn't delete autoloads, as documented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: For team assessment
Development

No branches or pull requests

3 participants