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

Crash when importing Terrain3D add-on for the first time (but not after restarting the editor) #80850

Closed
Calinou opened this issue Aug 21, 2023 · 10 comments

Comments

@Calinou
Copy link
Member

Calinou commented Aug 21, 2023

Godot version

4.2.dev c495eb5

System information

Godot v4.2.dev (c495eb5) - Fedora Linux 38 (KDE Plasma) - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4090 (nvidia; 535.98) - 13th Gen Intel(R) Core(TM) i9-13900K (32 Threads)

Issue description

The editor crashes when importing Terrain3D add-on for the first time (but not after restarting the editor). Relevant part of the log:

SCRIPT ERROR: Parse Error: Could not find type "Terrain3D" in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:11)
SCRIPT ERROR: Parse Error: Could not find type "Terrain3DEditor" in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:16)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:27)
SCRIPT ERROR: Parse Error: Could not find type "Terrain3D" in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:52)
SCRIPT ERROR: Parse Error: Could not find type "Terrain3D" in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:59)
SCRIPT ERROR: Parse Error: Could not find type "Terrain3DEditor" in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:125)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:127)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:130)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DStorage" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:131)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:132)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DStorage" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:133)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:134)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:140)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:144)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:148)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:149)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:165)
SCRIPT ERROR: Parse Error: Could not find type "Terrain3DSurface" in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:185)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:197)
SCRIPT ERROR: Parse Error: Identifier "Terrain3DEditor" not declared in the current scope.
at: GDScript::reload (res://addons/terrain_3d/editor/editor.gd:198)
ERROR: Failed to load script "res://addons/terrain_3d/editor/editor.gd" with error "Parse error".
at: load (modules/gdscript/gdscript.cpp:2700)
ERROR: Condition "is_compressed()" is true. Returning: USED_CHANNELS_RGBA
at: detect_used_channels (core/io/image.cpp:3325)
ERROR: Condition "is_compressed()" is true. Returning: USED_CHANNELS_RGBA
at: detect_used_channels (core/io/image.cpp:3325)
ERROR: Condition "is_compressed()" is true. Returning: USED_CHANNELS_RGBA
at: detect_used_channels (core/io/image.cpp:3325)
ERROR: Condition "is_compressed()" is true. Returning: USED_CHANNELS_RGBA
at: detect_used_channels (core/io/image.cpp:3325)
ERROR: FATAL: Condition "!exists" is true.
at: operator[] (./core/templates/hash_map.h:538)

Backtrace:

handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.2.dev.custom_build (c495eb5102278a110c14bbffbf833ed436d1594d)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib64/libc.so.6(+0x3db70) [0x7f7cb5244b70] (??:0)
[2] godot() [0xfb41c7] (/home/hugo/Documents/Git/godotengine/godot/./core/templates/hash_map.h:538 (discriminator 3))
[3] godot() [0xfc68ee] (/home/hugo/Documents/Git/godotengine/godot/modules/gdscript/gdscript_compiler.cpp:2983)
[4] godot() [0xf48c21] (/home/hugo/Documents/Git/godotengine/godot/modules/gdscript/gdscript.cpp:787)
[5] godot() [0xfa9005] (/home/hugo/Documents/Git/godotengine/godot/modules/gdscript/gdscript_cache.cpp:302 (discriminator 1))
[6] godot() [0xf3d456] (/home/hugo/Documents/Git/godotengine/godot/./core/templates/cowdata.h:412)
[7] godot() [0x4df9f72] (/home/hugo/Documents/Git/godotengine/godot/./core/object/ref_counted.h:61)
[8] godot() [0x4dfa65a] (/home/hugo/Documents/Git/godotengine/godot/./core/templates/cowdata.h:412)
[9] godot() [0x4dfb652] (/home/hugo/Documents/Git/godotengine/godot/core/io/resource_loader.cpp:498)
[10] godot() [0x4dfcea8] (/home/hugo/Documents/Git/godotengine/godot/./core/object/ref_counted.h:201)
[11] godot() [0x1f2f617] (/home/hugo/Documents/Git/godotengine/godot/./core/object/ref_counted.h:109)
[12] godot() [0x1f32891] (/home/hugo/Documents/Git/godotengine/godot/editor/editor_file_system.cpp:1300)
[13] godot() [0x1f34391] (/home/hugo/Documents/Git/godotengine/godot/editor/editor_file_system.cpp:689)
[14] godot() [0x1f350ed] (/home/hugo/Documents/Git/godotengine/godot/editor/editor_file_system.cpp:1282)
[15] godot() [0x51a7f54] (/home/hugo/Documents/Git/godotengine/godot/core/object/object.cpp:800)
[16] godot() [0x3059bd7] (/home/hugo/Documents/Git/godotengine/godot/scene/main/scene_tree.cpp:948)
[17] godot() [0x305a66c] (/home/hugo/Documents/Git/godotengine/godot/scene/main/scene_tree.cpp:1025 (discriminator 1))
[18] godot() [0x305bcb0] (/home/hugo/Documents/Git/godotengine/godot/scene/main/scene_tree.cpp:510)
[19] godot() [0xb11ed5] (/home/hugo/Documents/Git/godotengine/godot/main/main.cpp:3462)
[20] godot() [0xaa4dc1] (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/os_linuxbsd.cpp:912 (discriminator 1))
[21] godot() [0xa9674a] (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/godot_linuxbsd.cpp:76)
[22] /lib64/libc.so.6(+0x27b4a) [0x7f7cb522eb4a] (??:0)
[23] /lib64/libc.so.6(__libc_start_main+0x8b) [0x7f7cb522ec0b] (??:0)
[24] godot() [0xaa2375] (??:?)
-- END OF BACKTRACE --

Looking at the backtrace, this is caused by GDScript rather than resource importing.

Steps to reproduce

Minimal reproduction project

https://github.com/outobugi/Terrain3D/releases/tag/v0.8.2-alpha_gd4.1.1

@jsjtxietian
Copy link
Contributor

jsjtxietian commented Aug 31, 2023

I can reproduce this bug with Godot v4.2.dev (f7c48cf) - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 (NVIDIA; 31.0.15.3619) - 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz (16 Threads)

But for me, it crashes most times. It seems like when loading Importer.gd, inside compile function calls ,globals doesnt have a Terrain3D element (from gdextension I suppose) in it but still trying to access it.

@Saul2022
Copy link

Saul2022 commented Sep 1, 2023

I had this before but i think cory fixed it already. TokisanGames/Terrain3D#196

@TokisanGames
Copy link
Contributor

TokisanGames commented Oct 17, 2023

I didn't know this ticket was made until now. I didn't fix it. I worked around it. The key change was something I copied from godot-jolt in the PR Saul mentioned. All it does is use an initialization mode that forces a prompt to restart rather than just crashing.

terrain_library_init()
	init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); --> crashes
	init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SERVERS); --> prompts for restart

My instructions are now to restart twice before using:

  • Load godot for the first time, restart when it prompts (it would still crash right now here without the above change).
    Godot restarts, then imports assets like SVGs.
  • Restart again
    Then it loads w/o errors or warnings

It looks like it may have been addressed with these:
godotengine/godot-cpp#1249
#82294
#82771
#82784

@capnm
Copy link
Contributor

capnm commented Oct 17, 2023

Only the resulting »crash« was prevented, the actual GDExtension initialization issue caused by missing
(and too late generating) the .godot/extension_list.cfg file is still present.

@dsnopek
Copy link
Contributor

dsnopek commented Oct 21, 2023

Poking around the code a little bit, it looks like EditorFileSystem::_scan_extensions() is what builds the .godot/extension-list.cfg. So, it'd be a matter of somehow making that happen much earlier.

@capnm
Copy link
Contributor

capnm commented Oct 21, 2023

  • grep _scan_extensions
editor/editor_file_system.cpp:671:      if (_scan_extensions()) {
editor/editor_file_system.cpp:2459:
    static void _scan_extensions_dir(EditorFileSystemDirectory *d, HashSet<String> &extensions) {
editor/editor_file_system.cpp:2468:             _scan_extensions_dir(d->get_subdir(i), extensions);
editor/editor_file_system.cpp:2471:bool EditorFileSystem::_scan_extensions() {
editor/editor_file_system.cpp:2475:     _scan_extensions_dir(d, extensions);
editor/editor_file_system.h:292:        bool _scan_extensions();
  • grep get_extension_list_config_file
core/extension/gdextension.cpp:45:String GDExtension::get_extension_list_config_file() {
core/extension/gdextension.h:119:       static String get_extension_list_config_file();
core/extension/gdextension_manager.cpp:229:     Ref<FileAccess> f = FileAccess::open(GDExtension::get_extension_list_config_file(), FileAccess::READ);
editor/editor_file_system.cpp:2495:     String extension_list_config_file = GDExtension::get_extension_list_config_file();
editor/export/editor_export_platform.cpp:852:   String extension_list_config_file = GDExtension::get_extension_list_config_file();
  • GDExtensionManager::load_extensions()
    This is called early enough and is broken for invalid file.
    Should probably try to create new one , see _scan_extensions_dir .
bin/godot.linuxbsd.editor.dev.x86_64.llvm -v --headless --quit 
[W] Extension file res://.godot/extension_list.cfg is not valid, creating new one.
   at: load_extensions (./core/extension/gdextension_manager.cpp:270)
Godot Engine v4.2.m23102121.custom_build.6543495b4 - https://godotengine.org
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
Using "default" pen tablet driver...
JoypadLinux: udev enabled and loaded successfully.
...

@capnm
Copy link
Contributor

capnm commented Nov 8, 2023

Update: Currently the hack executing godot --path <project> --headless --editor --quit
generates a correct extension_list.cfg file #84570

@akien-mga akien-mga added this to the 4.3 milestone Nov 11, 2023
@andreymal
Copy link

I ran into a similar issue while making a minimal project for #85268

v4.1.3 crashes with a similar backtrace if extension_list.cfg doesn't exist

v4.2-rc1 doesn't crash, but prints GDScript bug: Native class "MyEditorPluginBase" not found.

@MartinLyne
Copy link

Using the headless hack mentioned above doesn't seem to work for me using v4.2.stable.mono.official [46dc27791]

Is there a further workaround, perhaps a way to generate the extensions file externally? (Terrain3d would be my first plugin, I don't know if that matters)

@KoBeWi
Copy link
Member

KoBeWi commented Jul 28, 2024

No crash in 4.3
There are some errors that require editor restart, but it's likely the same as #92493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants