godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.01k stars 21.17k forks source link

Editor crash when accessing members of get_overlapping_areas() when stored in a variable within a subclass #95864

Closed afterlightgames closed 2 weeks ago

afterlightgames commented 2 months ago

Tested versions

v4.3.stable.official [77dcf97d8]

System information

Godot v4.3.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 32.0.15.5599) - AMD Ryzen 5 3600 6-Core Processor (12 Threads)

Issue description

The editor crashes when you store get_overlapping_areas() inside of a variable within a subclass that inherits Area2D and then try to access the method's members like so: image image

It's possible that this crash occurs with more than just the result of that specific method, but I haven't found any yet.

Steps to reproduce

  1. Create a new node and attach a new script
  2. Within that script, define a subclass that extends Area2D
  3. Define a function in the subclass and store the result of get_overlapping_areas() in a variable somewhere
  4. Try to access the variable's members (by typing _variablename.)

Minimal reproduction project (MRP)

mrp.zip

JekSun97 commented 2 months ago

Good find! Having tested MRP on 4.3, I can confirm that the failure does indeed occur.

I also tested this on 4.2.2, there is no crash there but an error occurs: err42

matheusmdx commented 2 months ago

Tested with latest master v4.4.dev.custom_build [826de7976], there is the point of the crash and the backtrace:

image

Backtrace ``` Area2D::get_overlapping_areas() Line 483 (c:\Users\Matheus\Downloads\Godot Source\scene\2d\physics\area_2d.cpp:483) call_with_variant_args_retc_helper>(Area2D * p_instance, TypedArray(const Area2D::*)() p_method, const Variant * * p_args, Variant & r_ret, Callable::CallError & r_error, IndexSequence<> __formal) Line 807 (c:\Users\Matheus\Downloads\Godot Source\core\variant\binder_common.h:807) call_with_variant_args_retc_dv>(Area2D * p_instance, TypedArray(const Area2D::*)() p_method, const Variant * * p_args, int p_argcount, Variant & r_ret, Callable::CallError & r_error, const Vector & default_values) Line 569 (c:\Users\Matheus\Downloads\Godot Source\core\variant\binder_common.h:569) MethodBindTRC>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Callable::CallError & r_error) Line 622 (c:\Users\Matheus\Downloads\Godot Source\core\object\method_bind.h:622) _guess_expression_type(GDScriptParser::CompletionContext & p_context, const GDScriptParser::ExpressionNode * p_expression, GDScriptCompletionIdentifier & r_type) Line 1870 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_editor.cpp:1870) _guess_identifier_type(GDScriptParser::CompletionContext & p_context, const GDScriptParser::IdentifierNode * p_identifier, GDScriptCompletionIdentifier & r_type) Line 2232 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_editor.cpp:2232) _guess_expression_type(GDScriptParser::CompletionContext & p_context, const GDScriptParser::ExpressionNode * p_expression, GDScriptCompletionIdentifier & r_type) Line 1655 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_editor.cpp:1655) GDScriptLanguage::complete_code(const String & p_code, const String & p_path, Object * p_owner, List * r_options, bool & r_forced, String & r_call_hint) Line 3296 (c:\Users\Matheus\Downloads\Godot Source\modules\gdscript\gdscript_editor.cpp:3296) ScriptTextEditor::_code_complete_script(const String & p_code, List * r_options, bool & r_force) Line 880 (c:\Users\Matheus\Downloads\Godot Source\editor\plugins\script_text_editor.cpp:880) ScriptTextEditor::_code_complete_scripts(void * p_ud, const String & p_code, List * r_options, bool & r_force) Line 869 (c:\Users\Matheus\Downloads\Godot Source\editor\plugins\script_text_editor.cpp:869) CodeTextEditor::_complete_request() Line 969 (c:\Users\Matheus\Downloads\Godot Source\editor\code_editor.cpp:969) call_with_variant_args_helper(CodeTextEditor * p_instance, void(CodeTextEditor::*)() p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<> __formal) Line 309 (c:\Users\Matheus\Downloads\Godot Source\core\variant\binder_common.h:309) call_with_variant_args(CodeTextEditor * p_instance, void(CodeTextEditor::*)() 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::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 1188 (c:\Users\Matheus\Downloads\Godot Source\core\object\object.cpp:1188) Node::emit_signalp(const StringName & p_name, const Variant * * p_args, int p_argcount) Line 3929 (c:\Users\Matheus\Downloads\Godot Source\scene\main\node.cpp:3929) Object::emit_signal<>(const StringName & p_name) Line 936 (c:\Users\Matheus\Downloads\Godot Source\core\object\object.h:936) CodeEdit::request_code_completion(bool p_force) Line 2076 (c:\Users\Matheus\Downloads\Godot Source\scene\gui\code_edit.cpp:2076) CodeTextEditor::_code_complete_timer_timeout() Line 958 (c:\Users\Matheus\Downloads\Godot Source\editor\code_editor.cpp:958) call_with_variant_args_helper(CodeTextEditor * p_instance, void(CodeTextEditor::*)() p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<> __formal) Line 309 (c:\Users\Matheus\Downloads\Godot Source\core\variant\binder_common.h:309) call_with_variant_args(CodeTextEditor * p_instance, void(CodeTextEditor::*)() 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::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 1188 (c:\Users\Matheus\Downloads\Godot Source\core\object\object.cpp:1188) Node::emit_signalp(const StringName & p_name, const Variant * * p_args, int p_argcount) Line 3929 (c:\Users\Matheus\Downloads\Godot Source\scene\main\node.cpp:3929) Object::emit_signal<>(const StringName & p_name) Line 936 (c:\Users\Matheus\Downloads\Godot Source\core\object\object.h:936) Timer::_notification(int p_what) Line 62 (c:\Users\Matheus\Downloads\Godot Source\scene\main\timer.cpp:62) Timer::_notificationv(int p_notification, bool p_reversed) Line 37 (c:\Users\Matheus\Downloads\Godot Source\scene\main\timer.h:37) Object::notification(int p_notification, bool p_reversed) Line 873 (c:\Users\Matheus\Downloads\Godot Source\core\object\object.cpp:873) SceneTree::_process_group(SceneTree::ProcessGroup * p_group, bool p_physics) Line 1019 (c:\Users\Matheus\Downloads\Godot Source\scene\main\scene_tree.cpp:1019) SceneTree::_process(bool p_physics) Line 1100 (c:\Users\Matheus\Downloads\Godot Source\scene\main\scene_tree.cpp:1100) SceneTree::process(double p_time) Line 582 (c:\Users\Matheus\Downloads\Godot Source\scene\main\scene_tree.cpp:582) Main::iteration() Line 4223 (c:\Users\Matheus\Downloads\Godot Source\main\main.cpp:4223) OS_Windows::run() Line 1666 (c:\Users\Matheus\Downloads\Godot Source\platform\windows\os_windows.cpp:1666) 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!00007ffc1b2f7374() (Unknown Source:0) ntdll.dll!00007ffc1cfbcc91() (Unknown Source:0) ```



I also tested this on 4.2.2, there is no crash there but an error occurs:

I got the crash in this version too, seems to be something random, sometimes crash, sometimes gives the error

https://github.com/user-attachments/assets/5d2dcec2-0752-4768-9208-61889d76c235

dalexeev commented 2 months ago

CC @HolonProduction

HolonProduction commented 2 months ago

Only triggers, if the node the script is attached to does not inherit Area2D, so probably we are trying to guess the return type on the inner class using the base value from the outer class (which we shouldn't).