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

Running GDScript test commands cause crash with a simple script #41701

Closed
Xrayez opened this issue Sep 2, 2020 · 2 comments
Closed

Running GDScript test commands cause crash with a simple script #41701

Xrayez opened this issue Sep 2, 2020 · 2 comments

Comments

@Xrayez
Copy link
Contributor

Xrayez commented Sep 2, 2020

Godot version:
3922883

OS/device including version:
Windows 10.

Issue description:
As revealed in #41355. Likely just need some fixes, but I wouldn't be surprised if those crashes are also caused by running those tests in more or less isolated test environment.

Tokenizer

I suspect this may have something to do with off-by-one error.

godot.windows.tools.64.exe!CowData<String>::get(int p_index) Line 151 (d:\src\godot\4\core\cowdata.h:151)
godot.windows.tools.64.exe!Vector<String>::operator[](int p_index) Line 89 (d:\src\godot\4\core\vector.h:89)
godot.windows.tools.64.exe!TestGDScript::test_tokenizer(const String & p_code, const Vector<String> & p_lines) Line 67 (d:\src\godot\4\modules\gdscript\tests\test_gdscript.cpp:67)
godot.windows.tools.64.exe!TestGDScript::test(TestGDScript::TestType p_type) Line 219 (d:\src\godot\4\modules\gdscript\tests\test_gdscript.cpp:219)
godot.windows.tools.64.exe!test_tokenizer() Line 165 (d:\src\godot\4\modules\gdscript\register_types.cpp:165)
godot.windows.tools.64.exe!test_main(int argc, char * * argv) Line 74 (d:\src\godot\4\tests\test_main.cpp:74)
godot.windows.tools.64.exe!Main::test_entrypoint(int argc, char * * argv, bool & tests_need_run) Line 458 (d:\src\godot\4\main\main.cpp:458)
godot.windows.tools.64.exe!widechar_main(int argc, wchar_t * * argv) Line 149 (d:\src\godot\4\platform\windows\godot_windows.cpp:149)
godot.windows.tools.64.exe!_main() Line 185 (d:\src\godot\4\platform\windows\godot_windows.cpp:185)
godot.windows.tools.64.exe!main(int argc, char * * argv) Line 199 (d:\src\godot\4\platform\windows\godot_windows.cpp:199)
godot.windows.tools.64.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 213 (d:\src\godot\4\platform\windows\godot_windows.cpp:213)
[Inline Frame] godot.windows.tools.64.exe!invoke_main() Line 102 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:102)
godot.windows.tools.64.exe!__scrt_common_main_seh() Line 288 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
kernel32.dll!00007ff80cd87bd4() (Unknown Source:0)
ntdll.dll!00007ff80e72ce51() (Unknown Source:0)

Parser

Works fine. 🙂

Compiler

Uninitialized map data root. If you add the following snippet before the call causing crash, it would just prevent it:

			if (GDScriptLanguage::get_singleton()->get_global_map().empty()) {
				break;
			}
godot.windows.tools.64.exe!Map<StringName,int,Comparator<StringName>,DefaultAllocator>::operator[](const StringName & p_key) Line 575 (d:\src\godot\4\core\map.h:575)
godot.windows.tools.64.exe!GDScriptCompiler::_parse_class_level(GDScript * p_script, const GDScriptParser::ClassNode * p_class, bool p_keep_state) Line 1917 (d:\src\godot\4\modules\gdscript\gdscript_compiler.cpp:1917)
godot.windows.tools.64.exe!GDScriptCompiler::compile(const GDScriptParser * p_parser, GDScript * p_script, bool p_keep_state) Line 2305 (d:\src\godot\4\modules\gdscript\gdscript_compiler.cpp:2305)
godot.windows.tools.64.exe!TestGDScript::test_compiler(const String & p_code, const String & p_script_path, const Vector<String> & p_lines) Line 156 (d:\src\godot\4\modules\gdscript\tests\test_gdscript.cpp:156)
godot.windows.tools.64.exe!TestGDScript::test(TestGDScript::TestType p_type) Line 225 (d:\src\godot\4\modules\gdscript\tests\test_gdscript.cpp:225)
godot.windows.tools.64.exe!test_compiler() Line 173 (d:\src\godot\4\modules\gdscript\register_types.cpp:173)
godot.windows.tools.64.exe!test_main(int argc, char * * argv) Line 74 (d:\src\godot\4\tests\test_main.cpp:74)
godot.windows.tools.64.exe!Main::test_entrypoint(int argc, char * * argv, bool & tests_need_run) Line 458 (d:\src\godot\4\main\main.cpp:458)
godot.windows.tools.64.exe!widechar_main(int argc, wchar_t * * argv) Line 149 (d:\src\godot\4\platform\windows\godot_windows.cpp:149)
godot.windows.tools.64.exe!_main() Line 185 (d:\src\godot\4\platform\windows\godot_windows.cpp:185)
godot.windows.tools.64.exe!main(int argc, char * * argv) Line 199 (d:\src\godot\4\platform\windows\godot_windows.cpp:199)
godot.windows.tools.64.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 213 (d:\src\godot\4\platform\windows\godot_windows.cpp:213)
[Inline Frame] godot.windows.tools.64.exe!invoke_main() Line 102 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:102)
godot.windows.tools.64.exe!__scrt_common_main_seh() Line 288 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
kernel32.dll!00007ff80cd87bd4() (Unknown Source:0)
ntdll.dll!00007ff80e72ce51() (Unknown Source:0)

Steps to reproduce:

  1. Create a script identical to the following (others may not crash the test environment):
# test.gd (at Godot source root)

extends Node

func _ready():
    pass
  1. Compile the engine with scons test=yes
  2. Run test commands for GDScript:
godot --test gdscript-tokenizer test.gd
godot --test gdscript-parser test.gd
godot --test gdscript-compiler test.gd

Minimal reproduction project:
The above snippet should be fine.

@vnen
Copy link
Member

vnen commented Sep 2, 2020

I suspect this may have something to do with off-by-one error.

Yeah, this happens because the final dedent is implied and currently it's using the line number after the last. So either it should use the last line instead or not try to print it.

Uninitialized map data root. If you add the following snippet before the call causing crash, it would just prevent it:

We need to actually fill this map otherwise it will fail in other steps of the compilation process. Also applies to singletons. This can probably be added to the test function itself.

@YuriSizov
Copy link
Contributor

We now have extensive tests for GDScript and this hasn't been an issue, so I assume it's fixed by now.

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

4 participants