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

Pressing shift+delete with a multi-cursor selection crashes the editor #83826

Closed
Yagich opened this issue Oct 23, 2023 · 4 comments · Fixed by #86978
Closed

Pressing shift+delete with a multi-cursor selection crashes the editor #83826

Yagich opened this issue Oct 23, 2023 · 4 comments · Fixed by #86978

Comments

@Yagich
Copy link
Contributor

Yagich commented Oct 23, 2023

Godot version

4.2b2

System information

Linux/Manjaro

Issue description

If you have a multi-caret selection in the editor's CodeEdit and try to delete lines with Shift+Delete, the editor will crash.

Steps to reproduce

  1. Open any text file in the editor's CodeEdit
  2. Add another cursor
  3. Press Shift+Del
  4. The editor crashes

Minimal reproduction project

N/A

@atirut-w
Copy link
Contributor

I can reproduce this issue the older v4.1.2.stable.official [399c9dc]. Note that for the editor to crash, the cursors has to be on different lines.

@akien-mga
Copy link
Member

I can confirm the crash in 4.2.beta2.official and in a dev build from the master branch (8c25a98).

It doesn't crash systematically, and I haven't narrowed down the exact condition which triggers it, but any attempt at Shift+Delete does print errors (and eventually may crash).

ERROR: Index p_caret = 4 is out of bounds (carets.size() = 4).
   at: get_caret_line (./scene/gui/text_edit.cpp:4869)
ERROR: Index p_caret = 4 is out of bounds (carets.size() = 4).
   at: set_caret_line (./scene/gui/text_edit.cpp:4808)
ERROR: Index p_caret = 4 is out of bounds (carets.size() = 4).
   at: get_caret_line (./scene/gui/text_edit.cpp:4869)
ERROR: Index p_caret = 4 is out of bounds (carets.size() = 4).
   at: set_caret_column (./scene/gui/text_edit.cpp:4874)
ERROR: Index p_caret = 2 is out of bounds (carets.size() = 2).
   at: get_caret_line (./scene/gui/text_edit.cpp:4869)
ERROR: Index p_caret = 2 is out of bounds (carets.size() = 2).
   at: set_caret_line (./scene/gui/text_edit.cpp:4808)
ERROR: Index p_caret = 2 is out of bounds (carets.size() = 2).
   at: get_caret_line (./scene/gui/text_edit.cpp:4869)
ERROR: Index p_caret = 2 is out of bounds (carets.size() = 2).
   at: set_caret_column (./scene/gui/text_edit.cpp:4874)
ERROR: Index p_line = 1 is out of bounds (text.size() = 1).
   at: get_line_wrap_index_at_column (./scene/gui/text_edit.cpp:5294)
ERROR: Index p_line = 1 is out of bounds (text.size() = 1).
   at: get_line_wrap_index_at_column (./scene/gui/text_edit.cpp:5294)
ERROR: Index p_line = 1 is out of bounds (text.size() = 1).
   at: get_indent_level (./scene/gui/text_edit.cpp:3472)
ERROR: FATAL: Index p_index = 1 is out of bounds (size() = 1).
   at: get (./core/templates/cowdata.h:158)

================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.2.beta.custom_build (8c25a98fdf68dc388eddaefa188f3386236cdfe4)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib64/libc.so.6(+0x36960) [0x7f35d2f77960] (??:0)
[2] CowData<TextEdit::Text::Line>::get(int) const (/home/akien/Projects/godot/godot.git/./core/templates/cowdata.h:158 (discriminator 7))
[3] Vector<TextEdit::Text::Line>::operator[](int) const (/home/akien/Projects/godot/godot.git/./core/templates/vector.h:96)
[4] TextEdit::Text::operator[](int) const (/home/akien/Projects/godot/godot.git/./scene/gui/text_edit.cpp:145)
[5] TextEdit::_cut_internal(int) (/home/akien/Projects/godot/godot.git/./scene/gui/text_edit.cpp:6693)
[6] TextEdit::cut(int) (/home/akien/Projects/godot/godot.git/./scene/gui/text_edit.cpp:3717)
[7] TextEdit::gui_input(Ref<InputEvent> const&) (/home/akien/Projects/godot/godot.git/./scene/gui/text_edit.cpp:2136)
[8] CodeEdit::gui_input(Ref<InputEvent> const&) (/home/akien/Projects/godot/godot.git/./scene/gui/code_edit.cpp:568)
[9] Control::_call_gui_input(Ref<InputEvent> const&) (/home/akien/Projects/godot/godot.git/./scene/gui/control.cpp:1809)
[10] Viewport::_gui_input_event(Ref<InputEvent>) (/home/akien/Projects/godot/godot.git/./scene/main/viewport.cpp:2236)
[11] Viewport::push_input(Ref<InputEvent> const&, bool) (/home/akien/Projects/godot/godot.git/./scene/main/viewport.cpp:3185)
[12] Window::_window_input(Ref<InputEvent> const&) (/home/akien/Projects/godot/godot.git/./scene/main/window.cpp:1551)
[13] void call_with_variant_args_helper<Window, Ref<InputEvent> const&, 0ul>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, Callable::CallError&, IndexSequence<0ul>) (/home/akien/Projects/godot/godot.git/./core/variant/binder_common.h:303 (discriminator 4))
[14] void call_with_variant_args<Window, Ref<InputEvent> const&>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, int, Callable::CallError&) (/home/akien/Projects/godot/godot.git/./core/variant/binder_common.h:418)
[15] CallableCustomMethodPointer<Window, Ref<InputEvent> const&>::call(Variant const**, int, Variant&, Callable::CallError&) const (/home/akien/Projects/godot/godot.git/./core/object/callable_method_pointer.h:105)
[16] Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const (/home/akien/Projects/godot/godot.git/./core/variant/callable.cpp:57)
[17] Variant Callable::call<Ref<InputEvent> >(Ref<InputEvent>) const (/home/akien/Projects/godot/godot.git/./core/variant/variant.h:847)
[18] DisplayServerX11::_dispatch_input_event(Ref<InputEvent> const&) (/home/akien/Projects/godot/godot.git/platform/linuxbsd/x11/display_server_x11.cpp:4001)
[19] DisplayServerX11::_dispatch_input_events(Ref<InputEvent> const&) (/home/akien/Projects/godot/godot.git/platform/linuxbsd/x11/display_server_x11.cpp:3978)
[20] Input::_parse_input_event_impl(Ref<InputEvent> const&, bool) (/home/akien/Projects/godot/godot.git/./core/input/input.cpp:750)
[21] Input::flush_buffered_events() (/home/akien/Projects/godot/godot.git/./core/input/input.cpp:1012)
[22] DisplayServerX11::process_events() (/home/akien/Projects/godot/godot.git/platform/linuxbsd/x11/display_server_x11.cpp:5072)
[23] OS_LinuxBSD::run() (/home/akien/Projects/godot/godot.git/platform/linuxbsd/os_linuxbsd.cpp:931)
[24] godot-git(main+0x15a) [0x5487540] (/home/akien/Projects/godot/godot.git/platform/linuxbsd/godot_linuxbsd.cpp:76)
[25] /lib64/libc.so.6(+0x236b7) [0x7f35d2f646b7] (??:0)
[26] /lib64/libc.so.6(__libc_start_main+0x85) [0x7f35d2f64775] (??:0)
[27] godot-git(_start+0x21) [0x5487321] (??:?)
-- END OF BACKTRACE --
================================================================
Aborted (core dumped)

@atirut-w
Copy link
Contributor

atirut-w commented Oct 23, 2023

I can't get a lot of information out of the debugger since the index operator is inlined, but the crash is triggered on line 624 in scene\gui\text_edit.cpp: char32_t c = text[get_caret_line(caret)][get_caret_column(caret) - 1];

It seems that the engine tried to access a character on a now-deleted column of text to do some checks related to adding matching parentheses since if you put your cursors on the beginning of the lines, the editor will not crash. Maybe a check should be added?

@Jordyfel
Copy link
Contributor

Jordyfel commented Nov 6, 2023

Related to #81535

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