You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to understand the loading logic of GDExtension briefly:
When I open the project from the project manager:
If it exists .godot/extension_list.cfg GDExtensionManager will load the dll and register the class written by itself as NATIVE in GDscript.
Compile all *.gd scripts.
Find and parse the new *.gdextension resources.
Again GDExtensionManager will load the dll and register the class written by itself as NATIVE in GDscript.
or
Not present .godot/extension_list.cfg.
Compile all *.gd scripts
Find and parse all *.gdextension resources.
FirstGDExtensionManager 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.
Repair method
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.
voidGDScriptByteCodeGenerator::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;
The issue description and CrashHandlerException stack trace look vaguely similar to #80850, but not sure how similar these issues are. Looks like Terrain3D gdextension implemented some changes to work around their problem: TokisanGames/Terrain3D#196
I have similar issues with linux scons based GDExtensions. After clearing godot caches, the first editor launch crashes. Backing up the extension_list.cfg file and copying it back to the empty .godot directory fixes the crash issue.
Godot version
4.1.1
System information
win
Issue description
Wrote a simple link library using GDExtension
After launching the game for the first time using the Godot engine, the engine crashes.
However, after crashed, as long as it is not deleted
.goidot
.Everything is normal,library Work according to my expectationsI tried to compile godot4.1.1 by myself.
When I ran it for the first time, I got more detailed errors,.
Steps to reproduce
I follow the Static typing rules when writing scripts.
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 asNATIVE
inGDscript
.*.gd
scripts.*.gdextension
resources.GDExtensionManager
will load the dll and register the class written by itself asNATIVE
inGDscript
.or
.godot/extension_list.cfg
.*.gd
scripts*.gdextension
resources.GDExtensionManager
will load the dll and register the class written by itself asNATIVE
inGDscript
.When the
*.gd
script is compiled without registration, the program crashes.Repair method
When
write_assign_with_conversion
judging whether the type is registeredI 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.Minimal reproduction project
extension_test.zip
The text was updated successfully, but these errors were encountered: