godotengine / godot

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

Editor crashes on importing .escn when using GDNativeLibrary #20141

Closed rafallus closed 6 years ago

rafallus commented 6 years ago

Godot version: Version: 3.1 https://github.com/godotengine/godot/pull/20118/commits/a684e853abfa7a9e29adec80c12daf2734adf176

OS/device including version: Windows 10 64-bits

Issue description: I'm using the Nim bindings provided by @endragor. When the nim library is loaded by the editor (which happens at project opening if some node uses a NativeScript) , if I add a .escn file to the project the editor tries to import the file but fails and crashes with the following message:

hidpi aware?
Using GLES3 video driver
OpenGL ES 3.0 Renderer: GeForce GTX 660 Ti/PCIe/SSE2
WASAPI: detected 2 channels
WASAPI: audio buffer frames: 1962 calculated latency: 44ms
CORE API HASH: -5541965927402287857
EDITOR API HASH: 8856103870062785257
load resource: res://default_env.tres
load resource: C:\Users/Fallo/AppData/Roaming/Godot/editor_settings-3.tres
EditorSettings: Load OK!
load resource: res://main.tscn
load resource: res://Scripts/nim_node.gdns
load resource: res://Scripts/nimlib.gdnlib
load resource: res://Scripts/nimlib.gdnlib (cached)
load resource: res://Scripts/nim_node.gdns (cached)
load resource: res://Scripts/nim_node.gdns (cached)
A foreign thread is created, but app is compiled without --threads:on. Bad things will happen if Nim code is invoked from this thread. If you see this warning when running the editor and you don't actually use threads, ignore it.
erasing C:\Users\Fallo\AppData\Roaming/Godot/projects/AnimImport-cf7556e448514c045821b432400d5d52/filesystem_update3
ERROR: : Unhandled Nim exception: Error: unhandled exception:  [NilAccessError]

   At: C:\Users\Fallo\.nimble\pkgs\godot-0.7.14\nim\godotnim.nim:838
CrashHandlerException: Program crashed
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[0] ???
[1] ???
[2] EditorSceneImporterESCN::import_scene (d:\users\fallo\documents\godot\source\editor\import\resource_importer_scene.cpp:1452)
[3] ResourceImporterScene::import (d:\users\fallo\documents\godot\source\editor\import\resource_importer_scene.cpp:1238)
[4] EditorFileSystem::_reimport_file (d:\users\fallo\documents\godot\source\editor\editor_file_system.cpp:1438)
[5] EditorFileSystem::reimport_files (d:\users\fallo\documents\godot\source\editor\editor_file_system.cpp:1593)
[6] EditorFileSystem::_update_scan_actions (d:\users\fallo\documents\godot\source\editor\editor_file_system.cpp:537)
[7] EditorFileSystem::_notification (d:\users\fallo\documents\godot\source\editor\editor_file_system.cpp:1060)
[8] EditorFileSystem::_notificationv (d:\users\fallo\documents\godot\source\editor\editor_file_system.h:101)
[9] Object::notification (d:\users\fallo\documents\godot\source\core\object.cpp:926)
[10] SceneTree::_notify_group_pause (d:\users\fallo\documents\godot\source\scene\main\scene_tree.cpp:946)
[11] SceneTree::idle (d:\users\fallo\documents\godot\source\scene\main\scene_tree.cpp:499)
[12] Main::iteration (d:\users\fallo\documents\godot\source\main\main.cpp:1800)
[13] OS_Windows::run (d:\users\fallo\documents\godot\source\platform\windows\os_windows.cpp:2591)
[14] widechar_main (d:\users\fallo\documents\godot\source\platform\windows\godot_win.cpp:150)
[15] _main (d:\users\fallo\documents\godot\source\platform\windows\godot_win.cpp:172)
[16] main (d:\users\fallo\documents\godot\source\platform\windows\godot_win.cpp:184)
[17] __scrt_common_main_seh (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283)
[18] BaseThreadInitThunk
-- END OF BACKTRACE --
Segmentation fault

When not using NativeScript the editor can import and open the scene without any problem.

Steps to reproduce: Add a NativeScript to a node (I'm using Nim bindings). After the editor has loaded the library (like after running the scene or re-opening the project) add a .escn.

Minimal reproduction project: AnimImport.zip

Zireael07 commented 6 years ago

I believe you should report this on the nim bindings repo?

rafallus commented 6 years ago

I'm not sure if this is Nim specific. Probably I could try with C++ bindings and see if it crashes.

rafallus commented 6 years ago

Using the C++ bindings I got the same editor crash:

hidpi aware? Using GLES3 video driver OpenGL ES 3.0 Renderer: GeForce GTX 660 Ti/PCIe/SSE2 WASAPI: detected 2 channels WASAPI: audio buffer frames: 1962 calculated latency: 44ms CORE API HASH: -5541965927402287857 EDITOR API HASH: 8856103870062785257 load resource: res://default_env.tres load resource: C:\Users/Fallo/AppData/Roaming/Godot/editor_settings-3.tres EditorSettings: Load OK! load resource: res://Main.tscn load resource: res://icon.png load resource: res://bin/gdexample.gdns load resource: res://bin/gdexample.gdnlib load resource: res://bin/gdexample.gdnlib (cached) load resource: res://icon.png (cached) load resource: res://bin/gdexample.gdns (cached) load resource: res://bin/gdexample.gdns (cached) CrashHandlerException: Program crashed Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues [0] ??? [1] ??? [2] EditorSceneImporterESCN::import_scene (d:\users\fallo\documents\godot\source\editor\import\resource_importer_scene.cpp:1452) [3] ResourceImporterScene::import (d:\users\fallo\documents\godot\source\editor\import\resource_importer_scene.cpp:1238) [4] EditorFileSystem::_reimport_file (d:\users\fallo\documents\godot\source\editor\editor_file_system.cpp:1438) [5] EditorFileSystem::reimport_files (d:\users\fallo\documents\godot\source\editor\editor_file_system.cpp:1593) [6] EditorFileSystem::_update_scan_actions (d:\users\fallo\documents\godot\source\editor\editor_file_system.cpp:537) [7] EditorFileSystem::_notification (d:\users\fallo\documents\godot\source\editor\editor_file_system.cpp:1060) [8] EditorFileSystem::_notificationv (d:\users\fallo\documents\godot\source\editor\editor_file_system.h:101) [9] Object::notification (d:\users\fallo\documents\godot\source\core\object.cpp:926) [10] SceneTree::_notify_group_pause (d:\users\fallo\documents\godot\source\scene\main\scene_tree.cpp:946) [11] SceneTree::idle (d:\users\fallo\documents\godot\source\scene\main\scene_tree.cpp:499) [12] Main::iteration (d:\users\fallo\documents\godot\source\main\main.cpp:1800) [13] OS_Windows::run (d:\users\fallo\documents\godot\source\platform\windows\os_windows.cpp:2591) [14] widechar_main (d:\users\fallo\documents\godot\source\platform\windows\godot_win.cpp:150) [15] _main (d:\users\fallo\documents\godot\source\platform\windows\godot_win.cpp:172) [16] main (d:\users\fallo\documents\godot\source\platform\windows\godot_win.cpp:184) [17] __scrt_common_main_seh (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283) [18] BaseThreadInitThunk -- END OF BACKTRACE -- Segmentation fault

So it's not Nim related, but GDNative related.

akien-mga commented 6 years ago

CC @karroffel

ghost commented 6 years ago

I have the same behaviour with using a NativeScript. It does work when renaming the .escn file to .tscn though. Maybe this can be used as a temporary workaround.

ghost commented 6 years ago

I have debugged the problem and found a solution. PR is https://github.com/godotengine/godot/pull/23223

Could you guys please have a look?

akien-mga commented 6 years ago

Fixed by #23223.