godotengine / godot

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

Editor Crashes On Autocomplete With Custom Classes In Some Circumstances #69779

Closed Krissalyce closed 1 year ago

Krissalyce commented 1 year ago

Godot version

v4.0.beta7.official [0bb1e89fb]

System information

Windows 10

Issue description

When using custom classes defined with class_name, and using typed gdscript, the editor crashes apparently when trying to autocomplete in some circumstances where a variable is set to an instance of that class via a typed function. Typing "." after that variable then crashes the editor, presumably as part of auto-complete.

Steps to reproduce

The crash is a bit difficult to describe, I have attached an MRP containing a script with four functions and comments as to where you need to type "." ; the crash happens 100% with the code that I have typed.

This occurs when implicitly typing the variable and when duck typing the variable, as well as when using safe lines. I did not determine whether or not this occurs with explicit typing, though it should persist the same as when using safe lines.

Minimal reproduction project

MRP Autocomplete Crash.zip

qarmin commented 1 year ago

Infinite recursion

Thread 1 "godot4" received signal SIGSEGV, Segmentation fault.
0x0000000003227e5a in _guess_identifier_type_from_base (p_context=<error reading variable: Cannot access memory at address 0x7fffff7feea8>, p_base=<error reading variable: Cannot access memory at address 0x7fffff7feea0>, p_identifier=<error reading variable: Cannot access memory at address 0x7fffff7fee98>, r_type=<error reading variable: Cannot access memory at address 0x7fffff7fee90>) at modules/gdscript/gdscript_editor.cpp:2046
2046    modules/gdscript/gdscript_editor.cpp: Directory not empty.
(gdb) backtrace
#0  0x0000000003227e5a in _guess_identifier_type_from_base (p_context=<error reading variable: Cannot access memory at address 0x7fffff7feea8>, 
    p_base=<error reading variable: Cannot access memory at address 0x7fffff7feea0>, p_identifier=<error reading variable: Cannot access memory at address 0x7fffff7fee98>, 
    r_type=<error reading variable: Cannot access memory at address 0x7fffff7fee90>) at modules/gdscript/gdscript_editor.cpp:2046
#1  0x0000000003227506 in _guess_identifier_type (p_context=..., p_identifier=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:1990
#2  0x00000000032237f1 in _guess_expression_type (p_context=..., p_expression=0x26b43590, r_type=...) at modules/gdscript/gdscript_editor.cpp:1387
#3  0x0000000003223ff6 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1500
#4  0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#5  0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#6  0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#7  0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#8  0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#9  0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#10 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#11 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#12 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#13 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#14 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#15 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#16 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#17 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#18 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#19 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#20 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#21 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#22 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#23 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#24 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#25 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#26 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#27 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#28 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#29 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#30 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#31 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#32 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#33 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
#34 0x0000000003229a2e in _guess_method_return_type_from_base (p_context=..., p_base=..., p_method=..., r_type=...) at modules/gdscript/gdscript_editor.cpp:2285
#35 0x0000000003224b77 in _guess_expression_type (p_context=..., p_expression=0x26b43890, r_type=...) at modules/gdscript/gdscript_editor.cpp:1616
Rodeo-McCabe commented 1 year ago

I have encountered this same problem, though I've never been able to reliably reproduce it.

Possibly related: https://github.com/godotengine/godot/issues/63199 and https://github.com/godotengine/godot/issues/58943