Repository: godot
Issue: GDScript crash when running game from command line and a script contains an error
Labels: bug,topic:core,topic:gdscript,crash

### Godot version

Godot 4 beta10

### System information

Windows 10 64 bits NVIDIA GeForce GTX 1060

### Issue description

I ran the game from the command line. Some errors printed because I had an error in a script, but very soon after Godot crashed. I didn't expect this.

Call stack:
```
0000000000000000() (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!GDScriptFunction::call(GDScriptInstance * p_instance, const Variant * * p_args, int p_argcount, Callable::CallError & r_err, GDScriptFunction::CallState * p_state) Line 2018 (godot4_fork\modules\gdscript\gdscript_vm.cpp:2018)
godot.windows.editor.dev.x86_64.exe!GDScript::_super_implicit_constructor(GDScript * p_script, GDScriptInstance * p_instance, Callable::CallError & r_error) Line 132 (godot4_fork\modules\gdscript\gdscript.cpp:132)
godot.windows.editor.dev.x86_64.exe!GDScript::_create_instance(const Variant * * p_args, int p_argcount, Object * p_owner, bool p_is_ref_counted, Callable::CallError & r_error) Line 159 (godot4_fork\modules\gdscript\gdscript.cpp:159)
godot.windows.editor.dev.x86_64.exe!GDScript::instance_create(Object * p_this) Line 407 (godot4_fork\modules\gdscript\gdscript.cpp:407)
godot.windows.editor.dev.x86_64.exe!Object::set_script(const Variant & p_script) Line 844 (godot4_fork\core\object\object.cpp:844)
godot.windows.editor.dev.x86_64.exe!Object::set(const StringName & p_name, const Variant & p_value, bool * r_valid) Line 256 (godot4_fork\core\object\object.cpp:256)
godot.windows.editor.dev.x86_64.exe!SceneState::instantiate(SceneState::GenEditState p_edit_state) Line 271 (godot4_fork\scene\resources\packed_scene.cpp:271)
godot.windows.editor.dev.x86_64.exe!PackedScene::instantiate(PackedScene::GenEditState p_edit_state) Line 1802 (godot4_fork\scene\resources\packed_scene.cpp:1802)
godot.windows.editor.dev.x86_64.exe!SceneState::instantiate(SceneState::GenEditState p_edit_state) Line 168 (godot4_fork\scene\resources\packed_scene.cpp:168)
godot.windows.editor.dev.x86_64.exe!PackedScene::instantiate(PackedScene::GenEditState p_edit_state) Line 1802 (godot4_fork\scene\resources\packed_scene.cpp:1802)
godot.windows.editor.dev.x86_64.exe!Main::start() Line 2996 (godot4_fork\main\main.cpp:2996)
godot.windows.editor.dev.x86_64.exe!widechar_main(int argc, wchar_t * * argv) Line 178 (godot4_fork\platform\windows\godot_windows.cpp:178)
godot.windows.editor.dev.x86_64.exe!_main() Line 203 (godot4_fork\platform\windows\godot_windows.cpp:203)
godot.windows.editor.dev.x86_64.exe!main(int argc, char * * argv) Line 217 (godot4_fork\platform\windows\godot_windows.cpp:217)
godot.windows.editor.dev.x86_64.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 231 (godot4_fork\platform\windows\godot_windows.cpp:231)
godot.windows.editor.dev.x86_64.exe!invoke_main() Line 107 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:107)
godot.windows.editor.dev.x86_64.exe!__scrt_common_main_seh() Line 288 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
godot.windows.editor.dev.x86_64.exe!__scrt_common_main() Line 331 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331)
godot.windows.editor.dev.x86_64.exe!WinMainCRTStartup(void * __formal) Line 17 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_winmain.cpp:17)
```

C++ context:
![image](https://user-images.githubusercontent.com/1311555/210636795-ce4f52db-7707-437c-a810-6985c3e0ffa0.png)

`GDScriptFunction::call` is trying to call a null method pointer.

Log (probably not very relevant):
```
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
ERROR: Error while getting subscript full script.
   at: (modules\gdscript\gdscript_analyzer.cpp:3165)
Error while getting subscript full script.
ERROR: Condition "!method" is true. Returning: false
   at: Variant::is_builtin_method_vararg (core\variant\variant_call.cpp:1341)
core\variant\variant_call.cpp:1341 - Condition "!method" is true. Returning: false
ERROR: Condition "!method" is true. Returning: 0
   at: Variant::get_builtin_method_argument_count (core\variant\variant_call.cpp:1267)
core\variant\variant_call.cpp:1267 - Condition "!method" is true. Returning: 0
ERROR: Condition "!method" is true. Returning: Variant::NIL
   at: Variant::get_builtin_method_return_type (core\variant\variant_call.cpp:1320)
core\variant\variant_call.cpp:1320 - Condition "!method" is true. Returning: Variant::NIL
ERROR: Condition "!method" is true. Returning: nullptr
   at: Variant::get_validated_builtin_method (core\variant\variant_call.cpp:1253)
core\variant\variant_call.cpp:1253 - Condition "!method" is true. Returning: nullptr
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://addons/zylann.block_builder/construct.gd:-1)
res://addons/zylann.block_builder/construct.gd:-1 - Compile Error:
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://addons/zylann.block_builder/construct_editor.gd:-1)
res://addons/zylann.block_builder/construct_editor.gd:-1 - Compile Error:
Loading resource: res://pilot/pilot_controller.tscn
Loading resource: res://drone/drone.tscn
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://addons/zylann.block_builder/construct.gd:-1)
res://addons/zylann.block_builder/construct.gd:-1 - Compile Error:
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
ERROR: Error while getting subscript full script.
   at: (modules\gdscript\gdscript_analyzer.cpp:3165)
Error while getting subscript full script.
ERROR: Condition "!method" is true. Returning: false
   at: Variant::is_builtin_method_vararg (core\variant\variant_call.cpp:1341)
core\variant\variant_call.cpp:1341 - Condition "!method" is true. Returning: false
ERROR: Condition "!method" is true. Returning: 0
   at: Variant::get_builtin_method_argument_count (core\variant\variant_call.cpp:1267)
core\variant\variant_call.cpp:1267 - Condition "!method" is true. Returning: 0
ERROR: Condition "!method" is true. Returning: Variant::NIL
   at: Variant::get_builtin_method_return_type (core\variant\variant_call.cpp:1320)
core\variant\variant_call.cpp:1320 - Condition "!method" is true. Returning: Variant::NIL
ERROR: Condition "!method" is true. Returning: nullptr
   at: Variant::get_validated_builtin_method (core\variant\variant_call.cpp:1253)
core\variant\variant_call.cpp:1253 - Condition "!method" is true. Returning: nullptr
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://addons/zylann.block_builder/construct.gd:-1)
res://addons/zylann.block_builder/construct.gd:-1 - Compile Error:
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://addons/zylann.block_builder/construct_editor.gd:-1)
res://addons/zylann.block_builder/construct_editor.gd:-1 - Compile Error:
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://addons/zylann.block_builder/construct.gd:-1)
res://addons/zylann.block_builder/construct.gd:-1 - Compile Error:
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://addons/zylann.block_builder/construct_serializer_json.gd:-1)
res://addons/zylann.block_builder/construct_serializer_json.gd:-1 - Compile Error:
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://pilot/pilot_controller.gd:-1)
res://pilot/pilot_controller.gd:-1 - Compile Error:
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://character/interaction.gd:-1)
res://character/interaction.gd:-1 - Compile Error:
Loading resource: res://gui/inventory/inventory_item.tscn
SCRIPT ERROR: Parse Error: Identifier "block_instance" not declared in the current scope.
          at: GDScript::reload (res://addons/zylann.block_builder/cluster.gd:96)
res://addons/zylann.block_builder/cluster.gd:96 - Parse Error: Identifier "block_instance" not declared in the current scope.
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://addons/zylann.block_builder/construct.gd:-1)
res://addons/zylann.block_builder/construct.gd:-1 - Compile Error:
SCRIPT ERROR: Compile Error:
          at: GDScript::reload (res://gui/ship_inspector/ship_inspector.gd:-1)
res://gui/ship_inspector/ship_inspector.gd:-1 - Compile Error:
Exception thrown at 0x0000000000000000 in godot.windows.editor.dev.x86_64.exe: 0xC0000005: Access violation executing location 0x0000000000000000.
```

### Steps to reproduce

Unfortunately this has just happened for the first time and I have no idea what combination of things causes it, beyond the fact a script contains an error. It looks like Godot tried to set a script on an object, but that script could not load because one of its dependencies had an error in it, and that somehow caused it to crash. Doing only that in an empty project doesn't reproduce it though, hence the importance of context and why an MRP is hard to get... I can get it every time though.
My project is not minimal and not open-source, and finding an MRP takes all my evenings when I try to get one with bugs like this... but I can provide the project in private from RocketChat if needed for investigation.

I wanted to report it though, because as I often run debug builds, I get immediate call stacks and C++ context when crashes occur.


### Minimal reproduction project

N.A