Skip to content

Editor crash when using a variable with the same name as an internal class in C++ code #105362

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

Open
felixmariotto opened this issue Apr 13, 2025 · 2 comments

Comments

@felixmariotto
Copy link

Tested versions

reproductible in: 4.4.1 [49a5bc7]

System information

Godot v4.4.1.stable (49a5bc7) - Windows 11 (build 26100) - Multi-window, 3 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Laptop GPU (NVIDIA; 32.0.15.7270) - Intel(R) Core(TM) i9-14900HX (32 threads)

Issue description

Description:
instantiating a preloaded PackedScene stored in a variable named GameView crashes the editor.

Steps to reproduce

Steps to reproduce:

  1. open up a blank Godot project, make a main scene with a script.
  2. make another scene, add a node (I tested with Node2D), save it.
  3. in the main scene script, add this script :

Image

  1. save the script. The editor should crash.

After some tests, it seems related to the name of the variable GameView. If you change it to let's say foo or GameViey, no crash. It looks like GameView is an undocumented global variable.

Minimal reproduction project (MRP)

Here is the packed project. You must open it in recovery mode, it crashes on startup due to the reported bug.
to_delete_2025-04-13_20-50-00.zip

@matheusmdx
Copy link
Contributor

Tested on 4.5 dev 2 and i can confirm the bug, seems to be not related with PackedSene, just needs a variable with the same name as some internal class in C++ code (tested using WindowWrapper and AnimationLibraryEditor classes).

# Variable without static typing: Crash
var WindowWrapper
WindowWrapper.call_something()

# Variable with static typing as Object, any Object derivated class or if you try to type as "Variant": Crash
var WindowWrapper: Object
WindowWrapper.call_something()

# Variable with static typing as any Variant type except Object derivated classes: No crash, just the expected parse errors
var WindowWrapper: int
WindowWrapper.call_something()

# Using casting: No crash, even with Object class
var WindowWrapper
(WindowWrapper as Object).call_something()

Seems a regression between 4.3 dev 6 and 4.3 beta 1, bisecting.

@github-project-automation github-project-automation bot moved this to For team assessment in GDScript Issue Triage Apr 13, 2025
@matheusmdx matheusmdx added this to the 4.5 milestone Apr 13, 2025
@matheusmdx matheusmdx changed the title Editor crash when instantiating a PackedScene named "GameView" Editor crash when using a variable with the same name as an internal class in C++ code Apr 13, 2025
@matheusmdx
Copy link
Contributor

Bisected to pr #91192. CC @vnen

Image

Backtrace
_can_use_validate_call(const MethodBind * p_method, const Vector<GDScriptCodeGenerator::Address> & p_arguments) Line 234 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_compiler.cpp:234)
GDScriptCompiler::_parse_expression(GDScriptCompiler::CodeGen & codegen, Error & r_error, const GDScriptParser::ExpressionNode * p_expression, bool p_root, bool p_initializer) Line 678 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_compiler.cpp:678)
GDScriptCompiler::_parse_block(GDScriptCompiler::CodeGen & codegen, const GDScriptParser::SuiteNode * p_block, bool p_add_locals, bool p_clear_locals) Line 2187 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_compiler.cpp:2187)
GDScriptCompiler::_parse_function(Error & r_error, GDScript * p_script, const GDScriptParser::ClassNode * p_class, const GDScriptParser::FunctionNode * p_func, bool p_for_ready, bool p_for_lambda) Line 2370 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_compiler.cpp:2370)
GDScriptCompiler::_compile_class(GDScript * p_script, const GDScriptParser::ClassNode * p_class, bool p_keep_state) Line 2889 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_compiler.cpp:2889)
GDScriptCompiler::compile(const GDScriptParser * p_parser, GDScript * p_script, bool p_keep_state) Line 3212 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_compiler.cpp:3212)
GDScript::reload(bool p_keep_state) Line 803 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript.cpp:803)
GDScriptCache::get_full_script(const String & p_path, Error & r_error, const String & p_owner, bool p_update_from_disk) Line 347 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_cache.cpp:347)
ResourceFormatLoaderGDScript::load(const String & p_path, const String & p_original_path, Error * r_error, bool p_use_sub_threads, float * r_progress, ResourceFormatLoader::CacheMode p_cache_mode) Line 2863 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript.cpp:2863)
ResourceLoader::_load(const String & p_path, const String & p_original_path, const String & p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error * r_error, bool p_use_sub_threads, float * r_progress) Line 268 (c:\Users\Matheus\Downloads\Godot Source\core\io\resource_loader.cpp:268)
ResourceLoader::_thread_load_function(void * p_userdata) Line 326 (c:\Users\Matheus\Downloads\Godot Source\core\io\resource_loader.cpp:326)
ResourceLoader::_load_start(const String & p_path, const String & p_type_hint, ResourceLoader::LoadThreadMode p_thread_mode, ResourceFormatLoader::CacheMode p_cache_mode) Line 529 (c:\Users\Matheus\Downloads\Godot Source\core\io\resource_loader.cpp:529)
ResourceLoaderText::load() Line 476 (c:\Users\Matheus\Downloads\Godot Source\scene\resources\resource_format_text.cpp:476)
ResourceFormatLoaderText::load(const String & p_path, const String & p_original_path, Error * r_error, bool p_use_sub_threads, float * r_progress, ResourceFormatLoader::CacheMode p_cache_mode) Line 1685 (c:\Users\Matheus\Downloads\Godot Source\scene\resources\resource_format_text.cpp:1685)
ResourceLoader::_load(const String & p_path, const String & p_original_path, const String & p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error * r_error, bool p_use_sub_threads, float * r_progress) Line 268 (c:\Users\Matheus\Downloads\Godot Source\core\io\resource_loader.cpp:268)
ResourceLoader::_thread_load_function(void * p_userdata) Line 326 (c:\Users\Matheus\Downloads\Godot Source\core\io\resource_loader.cpp:326)
ResourceLoader::_load_start(const String & p_path, const String & p_type_hint, ResourceLoader::LoadThreadMode p_thread_mode, ResourceFormatLoader::CacheMode p_cache_mode) Line 529 (c:\Users\Matheus\Downloads\Godot Source\core\io\resource_loader.cpp:529)
ResourceLoader::load(const String & p_path, const String & p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error * r_error) Line 446 (c:\Users\Matheus\Downloads\Godot Source\core\io\resource_loader.cpp:446)
EditorNode::load_scene(const String & p_scene, bool p_ignore_broken_deps, bool p_set_inherited, bool p_clear_errors, bool p_force_open_imported, bool p_silent_change_tab) Line 3956 (c:\Users\Matheus\Downloads\Godot Source\editor\editor_node.cpp:3956)
EditorNode::_load_open_scenes_from_config(Ref<ConfigFile> p_layout) Line 5051 (c:\Users\Matheus\Downloads\Godot Source\editor\editor_node.cpp:5051)
EditorNode::_load_editor_layout() Line 4975 (c:\Users\Matheus\Downloads\Godot Source\editor\editor_node.cpp:4975)
EditorNode::_sources_changed(bool p_exist) Line 1075 (c:\Users\Matheus\Downloads\Godot Source\editor\editor_node.cpp:1075)
call_with_variant_args_helper<EditorNode,bool,0>(EditorNode * p_instance, void(EditorNode::*)(bool) p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<0> __formal) Line 309 (c:\Users\Matheus\Downloads\Godot Source\core\variant\binder_common.h:309)
call_with_variant_args<EditorNode,bool>(EditorNode * p_instance, void(EditorNode::*)(bool) p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 419 (c:\Users\Matheus\Downloads\Godot Source\core\variant\binder_common.h:419)
CallableCustomMethodPointer<EditorNode,bool>::call(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 104 (c:\Users\Matheus\Downloads\Godot Source\core\object\callable_method_pointer.h:104)
Callable::callp(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 58 (c:\Users\Matheus\Downloads\Godot Source\core\variant\callable.cpp:58)
Object::emit_signalp(const StringName & p_name, const Variant * * p_args, int p_argcount) Line 1216 (c:\Users\Matheus\Downloads\Godot Source\core\object\object.cpp:1216)
Node::emit_signalp(const StringName & p_name, const Variant * * p_args, int p_argcount) Line 3902 (c:\Users\Matheus\Downloads\Godot Source\scene\main\node.cpp:3902)
Object::emit_signal<bool>(const StringName & p_name, bool <p_args_0>) Line 935 (c:\Users\Matheus\Downloads\Godot Source\core\object\object.h:935)
EditorFileSystem::_notification(int p_what) Line 1299 (c:\Users\Matheus\Downloads\Godot Source\editor\editor_file_system.cpp:1299)
EditorFileSystem::_notificationv(int p_notification, bool p_reversed) Line 138 (c:\Users\Matheus\Downloads\Godot Source\editor\editor_file_system.h:138)
Object::notification(int p_notification, bool p_reversed) Line 902 (c:\Users\Matheus\Downloads\Godot Source\core\object\object.cpp:902)
SceneTree::_process_group(SceneTree::ProcessGroup * p_group, bool p_physics) Line 973 (c:\Users\Matheus\Downloads\Godot Source\scene\main\scene_tree.cpp:973)
SceneTree::_process(bool p_physics) Line 1050 (c:\Users\Matheus\Downloads\Godot Source\scene\main\scene_tree.cpp:1050)
SceneTree::process(double p_time) Line 529 (c:\Users\Matheus\Downloads\Godot Source\scene\main\scene_tree.cpp:529)
Main::iteration() Line 4031 (c:\Users\Matheus\Downloads\Godot Source\main\main.cpp:4031)
OS_Windows::run() Line 1673 (c:\Users\Matheus\Downloads\Godot Source\platform\windows\os_windows.cpp:1673)
widechar_main(int argc, wchar_t * * argv) Line 181 (c:\Users\Matheus\Downloads\Godot Source\platform\windows\godot_windows.cpp:181)
_main() Line 206 (c:\Users\Matheus\Downloads\Godot Source\platform\windows\godot_windows.cpp:206)
main(int argc, char * * argv) Line 220 (c:\Users\Matheus\Downloads\Godot Source\platform\windows\godot_windows.cpp:220)
WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 234 (c:\Users\Matheus\Downloads\Godot Source\platform\windows\godot_windows.cpp:234)
[Inline Frame] invoke_main() Line 102 (d:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:102)
__scrt_common_main_seh() Line 288 (d:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
kernel32.dll!00007ff941c77374() (Unknown Source:0)
ntdll.dll!00007ff9423fcc91() (Unknown Source:0)

Image


Related issue: #96743

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

No branches or pull requests

2 participants