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

gl on empty line selects to next line end #3

Closed
mawww opened this issue Jan 2, 2014 · 1 comment
Closed

gl on empty line selects to next line end #3

mawww opened this issue Jan 2, 2014 · 1 comment
Assignees

Comments

@mawww
Copy link
Owner

mawww commented Jan 2, 2014

It should not, gl is to line end, on an empty line we are already on it.

@ghost ghost assigned mawww Jan 3, 2014
@alexherbo2
Copy link
Contributor

it happens when selection is one more past the end of the line. for instance, xgl selects to next line end too.

@mawww mawww closed this as completed in 3be7784 Jan 3, 2014
krobelus added a commit to krobelus/kakoune that referenced this issue Mar 12, 2023
My terminal's workspace is configured to be displayed on an external
monitor if connected. When I connect my external monitor, the workspace
switches to that monitor and Kakoune segfaults consistently.
The crash happens in "TerminalUI::Screen::output" where we access a
dangling reference

	    auto output_line = [&](const Line& line) {
	        ColumnCount pending_move = 0;
	        for (auto& [text, skip, face] : line.atoms)
	        {
	/->          if (text.empty() and skip == 0)
	|                continue;
	|
	 cannot access memory referenced by "text"

The stack trace is

	Program received signal SIGSEGV, Segmentation fault.
	0x0000555555a5f1ac in Kakoune::String::Data::is_long (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:180
	(gdb) bt
	#0  0x0000555555a5f1ac in Kakoune::String::Data::is_long (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:180
	mawww#1  0x0000555555a5f1d6 in Kakoune::String::Data::size (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:181
	mawww#2  0x0000555555de34e4 in Kakoune::String::length (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:139
	mawww#3  Kakoune::StringOps<Kakoune::String, char>::empty (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:68
	mawww#4  operator() (__closure=0x7fffffffba50, line=...) at terminal_ui.cc:303
	mawww#5  0x0000555555de45aa in Kakoune::TerminalUI::Screen::output (this=0x5555560a7a60, force=true, synchronized=true, writer=...) at terminal_ui.cc:371
	mawww#6  0x0000555555de548a in Kakoune::TerminalUI::redraw (this=0x5555560a7a40, force=true) at terminal_ui.cc:535
	mawww#7  0x0000555555de579e in Kakoune::TerminalUI::refresh (this=0x5555560a7a40, force=true) at terminal_ui.cc:556
	mawww#8  0x0000555555a9ae71 in Kakoune::Client::redraw_ifn (this=0x55555609f9b0) at client.cc:284
	mawww#9  0x0000555555aab3db in Kakoune::ClientManager::redraw_clients (this=0x7fffffffd060) at client_manager.cc:233
	mawww#10 0x0000555555c86ef8 in Kakoune::run_server (session="", server_init="", client_init="", init_buffer="fish-rust/src/ast.rs", init_coord=..., flags=Kakoune::ServerFlags::None, ui_type=Kakoune::UIType::Terminal,
	    debug_flags=Kakoune::DebugFlags::None, files=ArrayView<Kakoune::StringView> = {...}) at main.cc:908
	mawww#11 0x0000555555c8bb76 in main (argc=2, argv=0x7fffffffe7b8) at main.cc:1263

We check for terminal resize in

	TerminalUI::TerminalUI
	TerminalUI::get_next_key
	TerminalUI::draw
	TerminalUI::suspend

I think neither of those happens when the window is moved.

Looks like TerminalUI::refresh relies on up-to-date dimensions,
so add a resize check here too, fixing the crash.
krobelus added a commit to krobelus/kakoune that referenced this issue Mar 12, 2023
When Kakoune's terminal is shown my laptop monitor and I plug in my
external monitor, the terminal's workspace will move to that external
monitor. When this happens, Kakoune segfaults consistently.

The crash happens in "TerminalUI::Screen::output" where we access a
dangling reference

	    auto output_line = [&](const Line& line) {
	        ColumnCount pending_move = 0;
	        for (auto& [text, skip, face] : line.atoms)
	        {
	/->          if (text.empty() and skip == 0)
	|                continue;
	|
	 cannot access memory referenced by "text"

The stack trace is

	Program received signal SIGSEGV, Segmentation fault.
	0x0000555555a5f1ac in Kakoune::String::Data::is_long (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:180
	(gdb) bt
	#0  0x0000555555a5f1ac in Kakoune::String::Data::is_long (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:180
	mawww#1  0x0000555555a5f1d6 in Kakoune::String::Data::size (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:181
	mawww#2  0x0000555555de34e4 in Kakoune::String::length (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:139
	mawww#3  Kakoune::StringOps<Kakoune::String, char>::empty (this=0x1a) at /home/johannes/git/kakoune/src/string.hh:68
	mawww#4  operator() (__closure=0x7fffffffba50, line=...) at terminal_ui.cc:303
	mawww#5  0x0000555555de45aa in Kakoune::TerminalUI::Screen::output (this=0x5555560a7a60, force=true, synchronized=true, writer=...) at terminal_ui.cc:371
	mawww#6  0x0000555555de548a in Kakoune::TerminalUI::redraw (this=0x5555560a7a40, force=true) at terminal_ui.cc:535
	mawww#7  0x0000555555de579e in Kakoune::TerminalUI::refresh (this=0x5555560a7a40, force=true) at terminal_ui.cc:556
	mawww#8  0x0000555555a9ae71 in Kakoune::Client::redraw_ifn (this=0x55555609f9b0) at client.cc:284
	mawww#9  0x0000555555aab3db in Kakoune::ClientManager::redraw_clients (this=0x7fffffffd060) at client_manager.cc:233
	mawww#10 0x0000555555c86ef8 in Kakoune::run_server (session="", server_init="", client_init="", init_buffer="fish-rust/src/ast.rs", init_coord=..., flags=Kakoune::ServerFlags::None, ui_type=Kakoune::UIType::Terminal,
	    debug_flags=Kakoune::DebugFlags::None, files=ArrayView<Kakoune::StringView> = {...}) at main.cc:908
	mawww#11 0x0000555555c8bb76 in main (argc=2, argv=0x7fffffffe7b8) at main.cc:1263

We check for terminal resize in

	TerminalUI::TerminalUI
	TerminalUI::get_next_key
	TerminalUI::draw
	TerminalUI::suspend

I think neither of those happens when the window is moved.

Looks like TerminalUI::refresh relies on up-to-date dimensions,
so add a resize check here too, fixing the crash.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants