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.do_unindent crashes Godot #68154

Closed
qarmin opened this issue Nov 2, 2022 · 0 comments · Fixed by #60904
Closed

Executing CodeEdit.do_unindent crashes Godot #68154

qarmin opened this issue Nov 2, 2022 · 0 comments · Fixed by #60904

Comments

@qarmin
Copy link
Contributor

qarmin commented Nov 2, 2022

Godot version

4.0.beta.custom_build. 0a0e99c

System information

Ubuntu 22.04 - Nvidia GTX 970, Gnome shell 42 X11

Issue description

extends Node
func _process(delta):

	var temp_variable382 = CodeEdit.new()
	add_child(temp_variable382)
	temp_variable382.set_indent_using_spaces(true)
	temp_variable382.indent_lines()
	temp_variable382.add_caret(-24, -19)
	temp_variable382.do_unindent()

Godot crashes with this backtrace

ERROR: Index p_index = 3 is out of bounds (size() = 0).
   at: get (./core/templates/cowdata.h:155)

================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.0.beta.custom_build (0a0e99cadc6e250ff2ee27ef31760eb9c2e21040)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fcc9ac2a520] (??:0)
[2] CowData<char32_t>::get(int) const (/home/runner/work/GodotBuilds/GodotBuilds/godot/./core/templates/cowdata.h:155 (discriminator 7))
[3] String::operator[](int) const (/home/runner/work/GodotBuilds/GodotBuilds/godot/./core/string/ustring.h:223)
[4] CodeEdit::do_unindent() (/home/runner/work/GodotBuilds/GodotBuilds/godot/scene/gui/code_edit.cpp:903 (discriminator 1))
[5] void call_with_variant_args_helper<__UnexistingClass>(__UnexistingClass*, void (__UnexistingClass::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (/home/runner/work/GodotBuilds/GodotBuilds/godot/./core/variant/binder_common.h:267 (discriminator 4))
[6] void call_with_variant_args_dv<__UnexistingClass>(__UnexistingClass*, void (__UnexistingClass::*)(), Variant const**, int, Callable::CallError&, Vector<Variant> const&) (/home/runner/work/GodotBuilds/GodotBuilds/godot/./core/variant/binder_common.h:410)
[7] MethodBindT<>::call(Object*, Variant const**, int, Callable::CallError&) (/home/runner/work/GodotBuilds/GodotBuilds/godot/./core/object/method_bind.h:320)
[8] Object::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/GodotBuilds/GodotBuilds/godot/core/object/object.cpp:733 (discriminator 1))
[9] Variant::callp(StringName const&, Variant const**, int, Variant&, Callable::CallError&) (/home/runner/work/GodotBuilds/GodotBuilds/godot/core/variant/variant_call.cpp:1048)
[10] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/home/runner/work/GodotBuilds/GodotBuilds/godot/modules/gdscript/gdscript_vm.cpp:1556)
[11] GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/GodotBuilds/GodotBuilds/godot/modules/gdscript/gdscript.cpp:1634)
[12] bool Node::_gdvirtual__process_call<false>(double) (/home/runner/work/GodotBuilds/GodotBuilds/godot/scene/main/node.h:238 (discriminator 5))
[13] Node::_notification(int) (/home/runner/work/GodotBuilds/GodotBuilds/godot/scene/main/node.cpp:57)
[14] Node::_notificationv(int, bool) (/home/runner/work/GodotBuilds/GodotBuilds/godot/./scene/main/node.h:45 (discriminator 14))
[15] Object::notification(int, bool) (/home/runner/work/GodotBuilds/GodotBuilds/godot/core/object/object.cpp:792)
[16] SceneTree::_notify_group_pause(StringName const&, int) (/home/runner/work/GodotBuilds/GodotBuilds/godot/scene/main/scene_tree.cpp:868)
[17] SceneTree::process(double) (/home/runner/work/GodotBuilds/GodotBuilds/godot/scene/main/scene_tree.cpp:468)
[18] Main::iteration() (/home/runner/work/GodotBuilds/GodotBuilds/godot/main/main.cpp:3170)
[19] OS_LinuxBSD::run() (/home/runner/work/GodotBuilds/GodotBuilds/godot/platform/linuxbsd/os_linuxbsd.cpp:776)
[20] godot4(main+0x19f) [0x2641a15] (/home/runner/work/GodotBuilds/GodotBuilds/godot/platform/linuxbsd/godot_linuxbsd.cpp:75)
[21] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fcc9ac11d90] (??:0)
[22] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7fcc9ac11e40] (??:0)
[23] godot4(_start+0x25) [0x26417b5] (??:?)
-- END OF BACKTRACE --
================================================================

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.

Steps to reproduce

Above

Minimal reproduction project

No response

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.

2 participants