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

GDScript regression: Compiler bug: unresolved assign #94654

Closed
akien-mga opened this issue Jul 23, 2024 · 2 comments · Fixed by #94730
Closed

GDScript regression: Compiler bug: unresolved assign #94654

akien-mga opened this issue Jul 23, 2024 · 2 comments · Fixed by #94730

Comments

@akien-mga
Copy link
Member

Tested versions

System information

Fedora Linux 40 (KDE Plasma) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 7600M XT (RADV NAVI33) - AMD Ryzen 7 7840HS w/ Radeon 780M Graphics (16 Threads)

Issue description

Moving one of the two regressions identified in #94244 to its own issue, as #94617 fixes the other one and will solve the original report from #94244.

The MRP (not really minimal, it's an empty project with Zylann's hterrain plugin installed), triggers the following error since #89990:

ERROR: Compiler bug: unresolved assign.
   at: write_assign_with_conversion (modules/gdscript/gdscript_byte_codegen.cpp:919)

This is still reproducible after #94617 too.

Steps to reproduce

  • Open MRP, see console output

Minimal reproduction project (MRP)

Reproduction project (empty project with Zylann hterrain installed):
hterraintest.zip

@akien-mga
Copy link
Member Author

I put a breakpoint to identify which scripts triggers the error, I'll see if I can make a smaller MRP:

Thread 1 "godot-git" hit Breakpoint 1, GDScriptByteCodeGenerator::write_assign_with_conversion (this=0x28adeae0, p_target=..., p_source=...) at ./modules/gdscript/gdscript_byte_codegen.cpp:919
919                             ERR_PRINT("Compiler bug: unresolved assign.");
Missing separate debuginfos, use: dnf debuginfo-install alsa-lib-1.2.12-1.fc40.x86_64 bzip2-libs-1.0.8-18.fc40.x86_64 dbus-libs-1.14.10-3.fc40.x86_64 elfutils-libelf-0.191-4.fc40.x86_64 expat-2.6.2-1.fc40.x86_64 flac-libs-1.4.3-4.fc40.x86_64 fontconfig-2.15.0-6.fc40.x86_64 freetype-2.13.2-5.fc40.x86_64 glib2-2.80.3-1.fc40.x86_64 glibc-2.39-17.fc40.x86_64 graphite2-1.3.14-15.fc40.x86_64 gsm-1.0.22-6.fc40.x86_64 harfbuzz-8.5.0-1.fc40.x86_64 lame-libs-3.100-17.fc40.x86_64 libX11-1.8.9-1.fc40.x86_64 libX11-xcb-1.8.9-1.fc40.x86_64 libXau-1.0.11-6.fc40.x86_64 libXcursor-1.2.1-7.fc40.x86_64 libXext-1.3.6-1.fc40.x86_64 libXfixes-6.0.1-3.fc40.x86_64 libXi-1.8.1-5.fc40.x86_64 libXinerama-1.1.5-6.fc40.x86_64 libXrender-0.9.11-6.fc40.x86_64 libbrotli-1.1.0-3.fc40.x86_64 libcap-2.69-8.fc40.x86_64 libdrm-2.4.121-1.fc40.x86_64 libffi-3.4.4-7.fc40.x86_64 libgcc-14.1.1-7.fc40.x86_64 libpng-1.6.40-3.fc40.x86_64 libsndfile-1.2.2-2.fc40.x86_64 libstdc++-14.1.1-7.fc40.x86_64 libvorbis-1.3.7-10.fc40.x86_64 libxcb-1.17.0-1.fc40.x86_64 libxkbcommon-1.6.0-2.fc40.x86_64 libxml2-2.12.8-1.fc40.x86_64 libzstd-1.5.6-1.fc40.x86_64 mesa-vulkan-drivers-24.1.4-2.fc40.x86_64 mpg123-libs-1.31.3-4.fc40.x86_64 ncurses-libs-6.4-12.20240127.fc40.x86_64 opus-1.5.1-1.fc40.x86_64 pcre2-10.44-1.fc40.x86_64 systemd-libs-255.8-1.fc40.x86_64 xz-libs-5.4.6-3.fc40.x86_64 zlib-ng-compat-2.1.7-1.fc40.x86_64
(gdb) bt
#0  GDScriptByteCodeGenerator::write_assign_with_conversion (this=0x28adeae0, p_target=..., p_source=...) at ./modules/gdscript/gdscript_byte_codegen.cpp:919
#1  0x00000000066ebdba in GDScriptCompiler::_parse_block (this=0x7fffffffa360, codegen=..., p_block=0x28b49c20, p_add_locals=false, p_clear_locals=true) at ./modules/gdscript/gdscript_compiler.cpp:2164
#2  0x00000000066eb5e5 in GDScriptCompiler::_parse_block (this=0x7fffffffa360, codegen=..., p_block=0x28b4a500, p_add_locals=false, p_clear_locals=true) at ./modules/gdscript/gdscript_compiler.cpp:2050
#3  0x00000000066eb5e5 in GDScriptCompiler::_parse_block (this=0x7fffffffa360, codegen=..., p_block=0x279c6460, p_add_locals=true, p_clear_locals=true) at ./modules/gdscript/gdscript_compiler.cpp:2050
#4  0x00000000066eb2dd in GDScriptCompiler::_parse_block (this=0x7fffffffa360, codegen=..., p_block=0x28b32b40, p_add_locals=true, p_clear_locals=false) at ./modules/gdscript/gdscript_compiler.cpp:2015
#5  0x00000000066ed0c2 in GDScriptCompiler::_parse_function (this=0x7fffffffa360, r_error=@0x7fffffffa034: OK, p_script=0x2763d9b0, p_class=0x2875d710, p_func=0x2861c4e0, p_for_ready=false, p_for_lambda=false)
    at ./modules/gdscript/gdscript_compiler.cpp:2384
#6  0x00000000066f04e5 in GDScriptCompiler::_compile_class (this=0x7fffffffa360, p_script=0x2763d9b0, p_class=0x2875d710, p_keep_state=true) at ./modules/gdscript/gdscript_compiler.cpp:2905
#7  0x00000000066f1e09 in GDScriptCompiler::compile (this=0x7fffffffa360, p_parser=0x7fffffffa450, p_script=0x2763d9b0, p_keep_state=true) at ./modules/gdscript/gdscript_compiler.cpp:3231
#8  0x00000000066a2957 in GDScript::reload (this=0x2763d9b0, p_keep_state=true) at ./modules/gdscript/gdscript.cpp:839
#9  0x00000000066de825 in GDScriptCache::get_full_script (p_path=..., r_error=@0x7fffffffaf9c: OK, p_owner=..., p_update_from_disk=false) at ./modules/gdscript/gdscript_cache.cpp:359
#10 0x00000000066deae0 in GDScriptCache::finish_compiling (p_owner=...) at ./modules/gdscript/gdscript_cache.cpp:399
#11 0x00000000066f1ef5 in GDScriptCompiler::compile (this=0x7fffffffb2a0, p_parser=0x7fffffffb390, p_script=0x264ae720, p_keep_state=true) at ./modules/gdscript/gdscript_compiler.cpp:3246
#12 0x00000000066a2957 in GDScript::reload (this=0x264ae720, p_keep_state=true) at ./modules/gdscript/gdscript.cpp:839
#13 0x00000000066de825 in GDScriptCache::get_full_script (p_path=..., r_error=@0x7fffffffbf04: OK, p_owner=..., p_update_from_disk=true) at ./modules/gdscript/gdscript_cache.cpp:359
#14 0x00000000066af4aa in ResourceFormatLoaderGDScript::load (this=0xbac5340, p_path=..., p_original_path=..., r_error=0x7fffffffc0b4, p_use_sub_threads=false, r_progress=0x7fffffffc270, 
    p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE) at ./modules/gdscript/gdscript.cpp:2932
#15 0x000000000a76f64f in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE, r_error=0x7fffffffc0b4, p_use_sub_threads=false, 
    r_progress=0x7fffffffc270) at ./core/io/resource_loader.cpp:269
#16 0x000000000a76fcec in ResourceLoader::_thread_load_function (p_userdata=0x7fffffffc230) at ./core/io/resource_loader.cpp:323
#17 0x000000000a770bce in ResourceLoader::_load_start (p_path=..., p_type_hint=..., p_thread_mode=ResourceLoader::LOAD_THREAD_FROM_CURRENT, p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE)
    at ./core/io/resource_loader.cpp:526
#18 0x000000000a77067f in ResourceLoader::load (p_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_IGNORE, r_error=0x0) at ./core/io/resource_loader.cpp:444
#19 0x000000000796cad2 in EditorNode::set_addon_plugin_enabled (this=0xe886af0, p_addon=..., p_enabled=true, p_config_changed=false) at ./editor/editor_node.cpp:3662
--Type <RET> for more, q to quit, c to continue without paging--c
#20 0x0000000007956f04 in EditorNode::init_plugins (this=0xe886af0) at ./editor/editor_node.cpp:852
#21 0x000000000776a3db in EditorFileSystem::_first_scan_filesystem (this=0xe1a5320) at ./editor/editor_file_system.cpp:249
#22 0x000000000776e438 in EditorFileSystem::scan (this=0xe1a5320) at ./editor/editor_file_system.cpp:827
#23 0x00000000079558c0 in EditorNode::_notification (this=0xe886af0, p_what=17) at ./editor/editor_node.cpp:639
#24 0x0000000007a47244 in EditorNode::_notificationv (this=0xe886af0, p_notification=17, p_reversed=false) at ./editor/editor_node.h:126
#25 0x000000000abf03dc in Object::notification (this=0xe886af0, p_notification=17, p_reversed=false) at ./core/object/object.cpp:870
#26 0x00000000086ff244 in SceneTree::_process_group (this=0xe0565f0, p_group=0xe056848, p_physics=false) at ./scene/main/scene_tree.cpp:962
#27 0x00000000086ff7bd in SceneTree::_process (this=0xe0565f0, p_physics=false) at ./scene/main/scene_tree.cpp:1039
#28 0x00000000086fd7df in SceneTree::process (this=0xe0565f0, p_time=0.14999999999999947) at ./scene/main/scene_tree.cpp:526
#29 0x0000000005c02d17 in Main::iteration () at main/main.cpp:4103
#30 0x0000000005b4888e in OS_LinuxBSD::run (this=0x7fffffffd090) at platform/linuxbsd/os_linuxbsd.cpp:962
#31 0x0000000005b410b1 in main (argc=2, argv=0x7fffffffd6f8) at platform/linuxbsd/godot_linuxbsd.cpp:85
(gdb) frame 9
#9  0x00000000066de825 in GDScriptCache::get_full_script (p_path=..., r_error=@0x7fffffffaf9c: OK, p_owner=..., p_update_from_disk=false) at ./modules/gdscript/gdscript_cache.cpp:359
359             r_error = script->reload(true);
(gdb) print p_path
$1 = (const String &) @0x28375dd8: {_cowdata = {static MAX_INT = <optimized out>, static REF_COUNT_OFFSET = <optimized out>, static SIZE_OFFSET = <optimized out>, static DATA_OFFSET = <optimized out>, 
    _ptr = 0x274d60b0 U"res://addons/zylann.hterrain/tools/texture_editor/set_editor/texture_set_import_editor.gd"}, static _null = 0 U'\000', static _replacement_char = 65533 U'�'}

@akien-mga
Copy link
Member Author

akien-mga commented Jul 23, 2024

MRP:

func _ready():
	var _slots_data := []

	var slot_index = 0
	while slot_index < 2:
		var slot = Node.new()
		_slots_data.append(slot)
		slot_index += 1

	var slot : Node = _slots_data[slot_index]

The problem seems to come from the local slot in the while loop which somehow conflicts with the slot local in the parent scope.

If I rename either of them, the bug is resolved.

Edit: Even more minimal. The while seems to be needed too, but the condition doesn't have to make sense.

func _ready():
	var _slots_data := []

	while false:
		var slot = 42
		_slots_data.append(slot)

	var slot : int = _slots_data[0]

@akien-mga akien-mga moved this from Very Bad to Bad in 4.x Release Blockers Jul 24, 2024
@github-project-automation github-project-automation bot moved this to For team assessment in GDScript Issue Triage Jul 25, 2024
@dalexeev dalexeev moved this from For team assessment to In progress / Assigned in GDScript Issue Triage Jul 25, 2024
@dalexeev dalexeev moved this from In progress / Assigned to Fix pending review in GDScript Issue Triage Jul 25, 2024
@github-project-automation github-project-automation bot moved this from Fix pending review to Done in GDScript Issue Triage Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bad
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants