Closed BeyondXinXin closed 1 year ago
I tried to compile godot4.1.1
by myself.
When I ran it for the first time, I got more detailed errors, and I still couldn't locate the problem.
Godot Engine v4.1.1.stable.custom_build.bd6af8e0e - https://godotengine.org
OpenGL API 3.3.0 NVIDIA 532.09 - Compatibility - Using Device: NVIDIA - NVIDIA GeForce RTX 3050 Ti Laptop GPU
Editing project: F:/github/extension_test/game
Godot Engine v4.1.1.stable.custom_build.bd6af8e0e - https://godotengine.org
OpenGL API 3.3.0 NVIDIA 532.09 - Compatibility - Using Device: NVIDIA - NVIDIA GeForce RTX 3050 Ti Laptop GPU
ERROR: Condition "!texture_allocs_cache.has(p_id)" is true.
at: GLES3::Utilities::texture_free_data (F:\godot\drivers\gles3\storage\utilities.h:111)
ERROR: Cubemap Arrays are not supported in the GL Compatibility backend.
at: (drivers\gles3\storage\texture_storage.cpp:763)
ERROR: Attempting to use an uninitialized RID
at: (F:\godot\core/templates/rid_owner.h:199)
ERROR: Condition "!t" is true.
at: GLES3::TextureStorage::texture_free (drivers\gles3\storage\texture_storage.cpp:705)
ERROR: FATAL: Condition "!exists" is true.
at: HashMap<class StringName,int,struct HashMapHasherDefault,struct HashMapComparatorDefault<class StringName>,class DefaultTypedAllocator<struct HashMapElement<class StringName,int> > >::operator [] (F:\godot\core/templates/hash_map.h:504)
================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.1.1.stable.custom_build (bd6af8e0ea69167dd0627f3bd54f9105bda0f8b5)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] HashMap<StringName,int,HashMapHasherDefault,HashMapComparatorDefault<StringName>,DefaultTypedAllocator<HashMapElement<StringName,int> > >::operator[] (F:\godot\core\templates\hash_map.h:504)
[1] HashMap<StringName,int,HashMapHasherDefault,HashMapComparatorDefault<StringName>,DefaultTypedAllocator<HashMapElement<StringName,int> > >::operator[] (F:\godot\core\templates\hash_map.h:504)
[2] GDScriptByteCodeGenerator::write_assign_with_conversion (F:\godot\modules\gdscript\gdscript_byte_codegen.cpp:889)
[3] GDScriptCompiler::_parse_function (F:\godot\modules\gdscript\gdscript_compiler.cpp:2234)
[4] GDScriptCompiler::_compile_class (F:\godot\modules\gdscript\gdscript_compiler.cpp:2802)
[5] GDScriptCompiler::compile (F:\godot\modules\gdscript\gdscript_compiler.cpp:2962)
[6] GDScript::reload (F:\godot\modules\gdscript\gdscript.cpp:787)
[7] GDScriptCache::get_full_script (F:\godot\modules\gdscript\gdscript_cache.cpp:307)
[8] ResourceFormatLoaderGDScript::load (F:\godot\modules\gdscript\gdscript.cpp:2701)
[9] ResourceLoader::_load (F:\godot\core\io\resource_loader.cpp:260)
[10] ResourceLoader::_thread_load_function (F:\godot\core\io\resource_loader.cpp:318)
[11] ResourceLoader::_load_start (F:\godot\core\io\resource_loader.cpp:498)
[12] ResourceLoader::load (F:\godot\core\io\resource_loader.cpp:414)
[13] EditorFileSystem::_update_script_classes (F:\godot\editor\editor_file_system.cpp:1592)
[14] EditorFileSystem::_update_pending_script_classes (F:\godot\editor\editor_file_system.cpp:1623)
[15] EditorFileSystem::reimport_files (F:\godot\editor\editor_file_system.cpp:2335)
[16] EditorFileSystem::_update_scan_actions (F:\godot\editor\editor_file_system.cpp:690)
[17] EditorFileSystem::_notification (F:\godot\editor\editor_file_system.cpp:1282)
[18] EditorFileSystem::_notificationv (F:\godot\editor\editor_file_system.h:146)
[19] Object::notification (F:\godot\core\object\object.cpp:798)
[20] SceneTree::_process_group (F:\godot\scene\main\scene_tree.cpp:949)
[21] SceneTree::_process (F:\godot\scene\main\scene_tree.cpp:1026)
[22] SceneTree::process (F:\godot\scene\main\scene_tree.cpp:510)
[23] Main::iteration (F:\godot\main\main.cpp:3425)
[24] OS_Windows::run (F:\godot\platform\windows\os_windows.cpp:1479)
[25] widechar_main (F:\godot\platform\windows\godot_windows.cpp:182)
[26] _main (F:\godot\platform\windows\godot_windows.cpp:204)
[27] main (F:\godot\platform\windows\godot_windows.cpp:218)
[28] WinMain (F:\godot\platform\windows\godot_windows.cpp:232)
[29] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[30] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================
Thanks for the report!
Hm, so it looks like the fatal error stems from GDScriptByteCodeGenerator::write_assign_with_conversion()
.
Can you try commenting out different parts of your GDScript code until you can narrow down which specific bit is leading to this error? Perhaps GDScript is having issues converting to/from a type from GDExtension?
@dsnopek Hi. Thanks for the suggestion, I found the problem.
I follow the Static typing
rules when writing scripts
@onready var navigation_region: GridBasedNavigationRegion2D = $GridBasedNavigationRegion2D
I try to understand the loading logic of GDExtension
briefly:
When I open the project from the project manager:
.godot/extension_list.cfg
GDExtensionManager
will load the dll and register the class written by itself as NATIVE
in GDscript
.*.gd
scripts.*.gdextension
resources.GDExtensionManager
will load the dll and register the class written by itself as NATIVE
in GDscript
.or
.godot/extension_list.cfg
.*.gd
scripts*.gdextension
resources.GDExtensionManager
will load the dll and register the class written by itself as NATIVE
in GDscript
.When the *.gd
script is compiled without registration, the program crashes.
When write_assign_with_conversion
judging whether the type is registered
I don't know how to prompt the error properly.
Perhaps: Regardless of the existence of .godot/extension_list.cfg
, all resources in *.gdextension
should be parsed before starting to compile scripts.
void GDScriptByteCodeGenerator::write_assign_with_conversion(const Address &p_target, const Address &p_source) {
switch (p_target.type.kind) {
case GDScriptDataType::BUILTIN: {
...
} break;
case GDScriptDataType::NATIVE: {
if (!GDScriptLanguage::get_singleton()->get_global_map().has(p_target.type.native_type)) {
ERR_PRINT(vformat(R"(Compiler Could not find type "%s" in the current scope.)", p_target.type.native_type));
break;
}
int class_idx = GDScriptLanguage::get_singleton()->get_global_map()[p_target.type.native_type];
Variant nc = GDScriptLanguage::get_singleton()->get_global_array()[class_idx];
class_idx = get_constant_pos(nc) | (GDScriptFunction::ADDR_TYPE_CONSTANT << GDScriptFunction::ADDR_BITS);
append_opcode(GDScriptFunction::OPCODE_ASSIGN_TYPED_NATIVE);
append(p_target);
append(p_source);
append(class_idx);
} break;
Great catch, thanks!
If you don't feel confident making a PR, perhaps at least make an issue?
The problem definitely does appear to be on the Godot side. There could be a bug with when the order of when GDExtensions are loaded, and does really seem like there's a GDScript bug too, given that it should probably handle a missing class more gracefully than crashing the whole engine.
Okay, I'll close this and submit an issue to Godot
Godot version
4.1.1
godot-cpp version
(tags) godot-4.1.1-stable
System information
win64
Issue description
Wrote a simple link library using GDExtension After launching the game for the first time using the Godot engine, the engine crashes.
Error message:
However, after Flashback, as long as it is not deleted
.goidot
.Everything is normal,library Work according to my expectationsSteps to reproduce
Open engine, load project, engine prompt
ERROR: FATAL: Condition "!exists" is true.
Minimal reproduction project
extension_test.zip
code