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

Executing CodeEdit.add_caret_at_carets function crashes Godot #91440

Closed
qarmin opened this issue May 2, 2024 · 1 comment · Fixed by #91457
Closed

Executing CodeEdit.add_caret_at_carets function crashes Godot #91440

qarmin opened this issue May 2, 2024 · 1 comment · Fixed by #91457

Comments

@qarmin
Copy link
Contributor

qarmin commented May 2, 2024

Tested versions

4.3.dev. f91db3d

System information

Ubuntu 22.04 CI

Issue description

When executing (this code was automatically minimized, so it is possible, that an even more "minimal" project can be created)

extends Node
func _process(delta):
	var temp_variable406 = CodeEdit.new()
	add_child(temp_variable406)
	temp_variable406.set_line_gutter_item_color(-96, 23, Color(-29.5963592529297, 37.2766151428223, 52.9504318237305, 1))
	temp_variable406.set_multiple_carets_enabled(false)
	temp_variable406.duplicate_lines()
	temp_variable406.clear()
	temp_variable406.undo()
	temp_variable406.add_caret_at_carets(true)

Godot crashes:

Godot Engine v4.3.dev.custom_build - https://godotengine.org
thirdparty/harfbuzz/src/OT/name/../../hb-open-type.hh:543:11: runtime error: index 2 out of bounds for type 'NameRecord [1]'
thirdparty/harfbuzz/src/OT/name/../../hb-open-type.hh:543:11: runtime error: index 2 out of bounds for type 'NameRecord [1]'
ERROR: Index p_line = -96 is out of bounds (text.size() = 1).
   at: set_line_gutter_item_color (scene/gui/text_edit.cpp:6173)
ERROR: Index p_caret = -1 is out of bounds (carets.size() = 1).
   at: set_selection_origin_line (scene/gui/text_edit.cpp:5351)
ERROR: Index p_caret = -1 is out of bounds (carets.size() = 1).
   at: set_selection_origin_column (scene/gui/text_edit.cpp:5404)
ERROR: FATAL: Index p_index = -1 is out of bounds (((Vector<T> *)(this))->_cowdata.size() = 1).
   at: operator[] (./core/templates/vector.h:52)
================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.3.dev.custom_build
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] ./godot.linuxbsd.editor.dev.x86_64.san(+0x4009b42b) [0x558c0241142b] (/home/runner/work/Qarminer/Qarminer/godot/platform/linuxbsd/crash_handler_linuxbsd.cpp:61)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f3279842520] (??:0)
[3] VectorWriteProxy<TextEdit::Caret>::operator[](long) (/home/runner/work/Qarminer/Qarminer/godot/./core/templates/vector.h:52 (discriminator 7))
[4] TextEdit::add_caret_at_carets(bool) (/home/runner/work/Qarminer/Qarminer/godot/scene/gui/text_edit.cpp:4601)
[5] void call_with_variant_args_helper<__UnexistingClass, bool, 0ul>(__UnexistingClass*, void (__UnexistingClass::*)(bool), Variant const**, Callable::CallError&, IndexSequence<0ul>) (/home/runner/work/Qarminer/Qarminer/godot/./core/variant/binder_common.h:309 (discriminator 4))
[6] void call_with_variant_args_dv<__UnexistingClass, bool>(__UnexistingClass*, void (__UnexistingClass::*)(bool), Variant const**, int, Callable::CallError&, Vector<Variant> const&) (/home/runner/work/Qarminer/Qarminer/godot/./core/variant/binder_common.h:422)
[7] MethodBindT<bool>::call(Object*, Variant const**, int, Callable::CallError&) const (/home/runner/work/Qarminer/Qarminer/godot/./core/object/method_bind.h:344)
[8] Object::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/Qarminer/Qarminer/godot/core/object/object.cpp:842)
[9] Variant::callp(StringName const&, Variant const**, int, Variant&, Callable::CallError&) (/home/runner/work/Qarminer/Qarminer/godot/core/variant/variant_call.cpp:1212)
[10] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/home/runner/work/Qarminer/Qarminer/godot/modules/gdscript/gdscript_vm.cpp:1764)
[11] GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/Qarminer/Qarminer/godot/modules/gdscript/gdscript.cpp:1978)
[12] bool Node::_gdvirtual__process_call<false>(double) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/node.h:350 (discriminator 1))
[13] Node::_notification(int) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/node.cpp:58)
[14] Node::_notificationv(int, bool) (/home/runner/work/Qarminer/Qarminer/godot/./scene/main/node.h:49 (discriminator 14))
[15] Object::notification(int, bool) (/home/runner/work/Qarminer/Qarminer/godot/core/object/object.cpp:907)
[16] SceneTree::_process_group(SceneTree::ProcessGroup*, bool) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/scene_tree.cpp:963)
[17] SceneTree::_process(bool) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/scene_tree.cpp:1035 (discriminator 2))
[18] SceneTree::process(double) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/scene_tree.cpp:529)
[19] Main::iteration() (/home/runner/work/Qarminer/Qarminer/godot/main/main.cpp:4040)
[20] OS_LinuxBSD::run() (/home/runner/work/Qarminer/Qarminer/godot/platform/linuxbsd/os_linuxbsd.cpp:962)
[21] ./godot.linuxbsd.editor.dev.x86_64.san(main+0x4c7) [0x558c02410dc0] (/home/runner/work/Qarminer/Qarminer/godot/platform/linuxbsd/godot_linuxbsd.cpp:85)
[22] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f3279829d90] (??:0)
[23] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f3279829e40] (??:0)
[24] ./godot.linuxbsd.editor.dev.x86_64.san(_start+0x25) [0x558c02410835] (??:?)
-- END OF BACKTRACE --
================================================================
Aborted (core dumped)

This example was found by Godot fuzzer - Qarminer, so it is quite unlikelly that this code could be used in real project, but still this should be handled gracefully.

Memory leaks or asan backtraces are visible when using Godot build with sanitizers support - https://github.com/qarmin/GodotBuilds/actions (linux -> linux-editor-sanitizers)

Steps to reproduce

Above

Minimal reproduction project (MRP)

Above

@akien-mga
Copy link
Member

CC @kitbdev

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

Successfully merging a pull request may close this issue.

3 participants