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

inserting via [shift]+[ins] causes panic in stdin_handler #1292

Closed
hbiel opened this issue Apr 4, 2022 · 9 comments · Fixed by #1303
Closed

inserting via [shift]+[ins] causes panic in stdin_handler #1292

hbiel opened this issue Apr 4, 2022 · 9 comments · Fixed by #1303

Comments

@hbiel
Copy link

hbiel commented Apr 4, 2022

Basic information
zellij --version: zellij 0.27.0
uname -av or ver(Windows): Linux 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Further information

  1. copy some text (don't know if it matters, but for example 'running')
  2. try to insert it in a zellij session via [shift]+[ins]
  3. most of the times zellij forcefully exits producing the below log

Trace Log

  × Thread 'stdin_handler' panicked.
  ├─▶ At /github/home/.cache/Homebrew/cargo_cache/registry/src/github.com-1ecc6299db9ec823/termwiz-0.15.0/src/readbuf.rs:47:25
  ╰─▶ range start index 18446744073709551613 out of range for slice of length 7
         0: <zellij_utils::errors::Panic as core::fmt::Display>::fmt
         1: miette::handlers::graphical::GraphicalReportHandler::render_causes
         2: zellij_utils::errors::fmt_report
         3: zellij_utils::errors::handle_panic
         4: std::panicking::rust_panic_with_hook
         5: std::panicking::begin_panic_handler::{{closure}}
         6: std::sys_common::backtrace::__rust_end_short_backtrace
         7: rust_begin_unwind
         8: core::panicking::panic_fmt
         9: core::slice::index::slice_start_index_len_fail
        10: termwiz::readbuf::ReadBuffer::find_subsequence
        11: std::sys_common::backtrace::__rust_begin_short_backtrace
        12: core::ops::function::FnOnce::call_once{{vtable.shim}}
        13: std::sys::unix::thread::Thread::new::thread_start
        14: <unknown>
        15: clone
@sybert1ger
Copy link

sybert1ger commented Apr 5, 2022

I am having the same or related issue.

Basic information

zellij --version: zellij 0.27.0
tput lines: 31
tput cols: 127
uname -av: Linux swagger 5.13.19-4-pve #1 SMP PVE 5.13.19-9 (Mon, 07 Feb 2022 11:01:14 +0100) x86_64 GNU/Linux

Windows Terminal: Version: 1.11.3471.0
nvim --version: NVIM v0.6.1
bash --version: GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)

Further information
Zellij intermittently crashes when pasting text. First noticed when using nvim but also occurs at the command line.

  1. Copy some text.
  2. Paste text using +
  3. Zellij crashes with below output. Terminal prompt has portion of pasted text remaining.

Pasted Text: 2: zellij_utils::errors::fmt_report

× Thread 'stdin_handler' panicked.
├─▶ At /github/home/.cache/Homebrew/cargo_cache/registry/src/github.com-1ecc6299db9ec823/termwiz-0.15.0/src/readbuf.rs:47:25
╰─▶ range start index 18446744073709551614 out of range for slice of length 11
0: <zellij_utils::errors::Panic as core::fmt::Display>::fmt
1: miette::handlers::graphical::GraphicalReportHandler::render_causes
2: zellij_utils::errors::fmt_report
3: zellij_utils::errors::handle_panic
4: std::panicking::rust_panic_with_hook
5: std::panicking::begin_panic_handler::{{closure}}
6: std::sys_common::backtrace::__rust_end_short_backtrace
7: rust_begin_unwind
8: core::panicking::panic_fmt
9: core::slice::index::slice_start_index_len_fail
10: termwiz::readbuf::ReadBuffer::find_subsequence
11: std::sys_common::backtrace::__rust_begin_short_backtrace
12: core::ops::function::FnOnce::call_once{{vtable.shim}}
13: std::sys::unix::thread::Thread::new::thread_start
14: start_thread
15: clone

help: If you are seeing this message, it means that something went wrong.
Please report this error to the github issue.
(https://github.com/zellij-org/zellij/issues)

Also, if you want to see the backtrace, you can set the RUST_BACKTRACE environment variable to 1.

:fmt_report^[[201~
rick in swagger in /tmp/zellij-1000/zellij-log
-> tils::errors::fmt_report~c

Contents of zellij.log
INFO |zellij_client | 2022-04-05 09:45:55.561 [main ] [zellij-client/src/lib.rs:121]: Starting Zellij client!
INFO |zellij_server | 2022-04-05 09:45:55.564 [main ] [zellij-server/src/lib.rs:189]: Starting Zellij server!
INFO |zellij_server::wasm_vm | 2022-04-05 09:45:55.615 [wasm ] [zellij-server/src/wasm_vm.rs:87]: Wasm main thread starts
INFO |zellij_server::wasm_vm | 2022-04-05 09:46:06.565 [wasm ] [zellij-server/src/wasm_vm.rs:213]: wasm main thread exits

@imsnif
Copy link
Member

imsnif commented Apr 5, 2022

Hey, I'm trying to reproduce this and not having much luck. We recently switched to a new STDIN parsing library and it looks like it has some quirks with pasting.

Does one of you have a reliable way of reproducing this? If so, which terminal emulator are you using? Does it happen in other terminal emulators for you as well?

@tlinford
Copy link
Contributor

tlinford commented Apr 5, 2022

can reproduce this on wsl using windows terminal, added some logging at

let buf = os_input.read_from_stdin();

and this is the result:

INFO   |zellij_client::stdin_hand| 2022-04-05 19:20:54.984 [stdin_handler] [zellij-client/src/stdin_handler.rs:17]: read from stdin: [27, 91, 50, 48, 48, 126, 50, 27, 91, 50, 48, 49, 126]
... more bracketed paste events
INFO   |zellij_client::stdin_hand| 2022-04-05 19:21:05.338 [stdin_handler] [zellij-client/src/stdin_handler.rs:17]: read from stdin: [27, 91, 50, 48, 48, 126, 50, 27, 91, 50, 48, 49, 126]
INFO   |zellij_client::stdin_hand| 2022-04-05 19:21:05.490 [stdin_handler] [zellij-client/src/stdin_handler.rs:17]: read from stdin: [27, 91, 50, 48, 48, 126, 50]
INFO   |zellij_client::stdin_hand| 2022-04-05 19:21:05.490 [stdin_handler] [zellij-client/src/stdin_handler.rs:17]: read from stdin: [27, 91, 50, 48, 49, 126]

termwiz standalone panics with:

let buf: Vec<u8> = vec![27, 91, 50, 48, 48, 126, 50];
let mut input_parser = InputParser::new();
input_parser.parse(&buf, |e| println!("parsed event: {:?}", e), false);

although the error is a bit different:

thread 'main' panicked at 'attempt to subtract with overflow', /home/thomas/.cargo/registry/src/github.com-1ecc6299db9ec823/termwiz-0.15.0/src/input.rs:1240:58
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::panicking::panic
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:48:5
   3: termwiz::input::InputParser::process_bytes
             at /home/thomas/.cargo/registry/src/github.com-1ecc6299db9ec823/termwiz-0.15.0/src/input.rs:1240:58
   4: termwiz::input::InputParser::parse
             at /home/thomas/.cargo/registry/src/github.com-1ecc6299db9ec823/termwiz-0.15.0/src/input.rs:1340:9
   5: termwiz_test::main
             at ./src/main.rs:49:5
   6: core::ops::function::FnOnce::call_once
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

setting maybe_more to true does not make a difference.

EDIT:
reproduced the termwiz crash by running in release mode (integer overflows panic in debug mode but not in release) with:

    let buf1: Vec<u8> = vec![27, 91, 50, 48, 48, 126, 50];
    let buf2: Vec<u8> = vec![27, 91, 50, 48, 49, 126];
    let mut input_parser = InputParser::new();

    input_parser.parse(&buf1, |e| println!("parsed event: {:?}", e), false);
    input_parser.parse(&buf2, |e| println!("parsed event: {:?}", e), false);

@hbiel
Copy link
Author

hbiel commented Apr 5, 2022

I was also using windows terminal on wsl ubuntu.

But i just tested it with Alacritty and WezTerm and got the same behaviour.
It's pretty much reproduceable. Sometimes the pasting works but mostly zellij just crashes.

@tlinford
Copy link
Contributor

tlinford commented Apr 5, 2022

I was also using windows terminal on wsl ubuntu.

But i just tested it with Alacritty and WezTerm and got the same behaviour. It's pretty much reproduceable. Sometimes the pasting works but mostly zellij just crashes.

still running on windows though?

@hbiel
Copy link
Author

hbiel commented Apr 5, 2022

still running on windows though?

Yup

@tlinford
Copy link
Contributor

tlinford commented Apr 7, 2022

link to upstream pr: wez/wezterm#1832

@hbiel
Copy link
Author

hbiel commented Apr 8, 2022

I built the current main-branch from source and am using that build for now. So far i haven't had any problem.
Thanks for your quick response!

@tlinford
Copy link
Contributor

tlinford commented Apr 8, 2022

I built the current main-branch from source and am using that build for now. So far i haven't had any problem. Thanks for your quick response!

cool, thank you for testing it!

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.

4 participants