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

program crashes when showing help if terminal height is less than help modal height #63

Closed
MCord opened this issue May 16, 2020 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@MCord
Copy link
Contributor

MCord commented May 16, 2020

Describe the bug
program crashes when showing help if terminal height is less than help modal height

To Reproduce
Steps to reproduce the behavior:

  1. run gitui
  2. change the height of the terminal to a very short height (ex 15 chars)
  3. press h to display help

Expected behavior
A warning about the terminal height maybe but no crash.

Desktop (please complete the following information):

  • OS: Windows 10 / Debian
  • Version: master branch

Additional context
This is an issue when the tool is used in integrated terminals inside IDE where the user might resize the terminal often.

@extrawurst extrawurst added the bug Something isn't working label May 16, 2020
@extrawurst extrawurst self-assigned this May 16, 2020
@extrawurst
Copy link
Owner

good catch!

fixed:
image

@MCord
Copy link
Contributor Author

MCord commented May 16, 2020

That was fast! :)

@guss77
Copy link

guss77 commented May 20, 2020

With version 0.3.0, this still happens to me on a terminal with height of 18 lines.

@extrawurst
Copy link
Owner

@guss77 that's weird. I can't reproduce that anymore. can you run with logging enabled and send me the backtrace that should be dumped?

@extrawurst extrawurst reopened this May 20, 2020
@extrawurst
Copy link
Owner

@guss77 you can find details on how to enable logging in the readme: https://github.com/extrawurst/gitui#diagnostics

it would be great if you could share the generated log after gitui crashed to make sure it is not a duplicate of #72 for which I am waiting for the upstream to merge my PR

@guss77
Copy link

guss77 commented May 21, 2020

With diagnostics, the log for the crash has this:

08:01:09 [TRACE] (1) gitui::app: [src/app.rs:94] event: Key(KeyEvent { code: Char('h'), modifiers: NONE })
08:01:09 [ERROR] panic: PanicInfo { payload: Any, message: Some(index out of bounds: the len is 4860 but the index is 64828), location: Location { file: "/rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/slice/mod.rs", line: 2848, col: 14 } }
trace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>

@extrawurst
Copy link
Owner

Ok @guss77 I am still lost on this one. May I ask you a couple of questions to allow me to find this badboy:

  1. when you have a big enough terminal window - does the help window open?
  2. can you resize the terminal window without any crash while the help window is closed?
  3. if 1. was a yes - can you check if it only crashes when reducing width and height individually?
  4. can you imagine building gitui from source to get debug symbols in there?
  5. are you on discord and interested in helping finding this?

@guss77
Copy link

guss77 commented May 21, 2020

  1. yes.
  2. My testing up until now was always to start gitui in a small window - I'm using a "pull down terminal" application - when on a vertical screen, the %height of the terminal is fine, but when on a horizontal screen the %height of the terminal is too small for the help window and it crashes. When I test resizing the terminal while gitui is running, then if the help window is closed, resizing the terminal does not crash gitui, but if the help window is open - resizing to a size where the help window does not fit on the screen crashes the app immediately (I didn't try resizing all the way down, just smaller than the help window).
  3. Resizing width or height individually both crash the app if I reduce the size 1 row or column smaller than the size of the help window.
  4. yes. sure.
  5. I'm not running discord normally, but I have an account and can go online to help with that.

I'll review the build instructions and see if I can build gitui.

@extrawurst
Copy link
Owner

@guss77 thanks for going through with this. Please build from master it will dump diagnostics into the terminal once it crashes, so u don't have to run with logging.

Regarding discord it is the easiest if you come over to crossterm's discord server: https://discord.gg/K4nyTDB - looking forward to figure this out

@guss77
Copy link

guss77 commented May 22, 2020

Sorry it took me so long - Ubuntu 20.04 carries Rust 1.141 while gitui requires Rust 1.142.

With the current master debug build, I can't crash gitui by resizing the terminal, and the help screen shows fine for my use case (for which I reported the problem originally).

With more testing I concluded that vertical size is not a problem - I can resize the terminal down to 1 line and it still works, while when resizing horizontally, gitui crashes when going down to 14 characters of width - regardless of whether the help screen is on or not.

When crashing due to insufficient terminal width, I get this in stderr:

panic: PanicInfo { payload: Any, message: Some(Trying to access position outside the buffer: x=14, y=0, area=Rect { x: 0, y: 0, width: 14, height: 47 }), location: Location { file: "/home/odeda/.cargo/registry/src/github.com-1ecc6299db9ec823/tui-0.9.4/src/buffer.rs", line: 245, col: 9 } }
trace:
   0: gitui::set_panic_handlers::{{closure}}
             at src/main.rs:213
   1: std::panicking::rust_panic_with_hook
             at /usr/src/rustc-1.42.0/src/libstd/panicking.rs:476
   2: rust_begin_unwind
             at /usr/src/rustc-1.42.0/src/libstd/panicking.rs:380
   3: std::panicking::begin_panic_fmt
             at /usr/src/rustc-1.42.0/src/libstd/panicking.rs:334
   4: tui::buffer::Buffer::index_of
             at /home/odeda/.cargo/registry/src/github.com-1ecc6299db9ec823/tui-0.9.4/src/buffer.rs:245
   5: tui::buffer::Buffer::set_stringn
             at /home/odeda/.cargo/registry/src/github.com-1ecc6299db9ec823/tui-0.9.4/src/buffer.rs:319
   6: tui::buffer::Buffer::set_string
             at /home/odeda/.cargo/registry/src/github.com-1ecc6299db9ec823/tui-0.9.4/src/buffer.rs:303
   7: <tui::widgets::tabs::Tabs<T> as tui::widgets::Widget>::render
             at /home/odeda/.cargo/registry/src/github.com-1ecc6299db9ec823/tui-0.9.4/src/widgets/tabs.rs:128
   8: tui::terminal::Frame<B>::render_widget
             at /home/odeda/.cargo/registry/src/github.com-1ecc6299db9ec823/tui-0.9.4/src/terminal.rs:65
   9: gitui::app::App::draw_tabs
             at src/app.rs:328
  10: gitui::app::App::draw
             at src/app.rs:82
  11: gitui::draw::{{closure}}
             at src/main.rs:135
  12: tui::terminal::Terminal<B>::draw
             at /home/odeda/.cargo/registry/src/github.com-1ecc6299db9ec823/tui-0.9.4/src/terminal.rs:187
  13: gitui::draw
             at src/main.rs:135
  14: gitui::main
             at src/main.rs:105
  15: std::rt::lang_start::{{closure}}
             at /usr/src/rustc-1.42.0/src/libstd/rt.rs:67
  16: std::rt::lang_start_internal::{{closure}}
             at /usr/src/rustc-1.42.0/src/libstd/rt.rs:52
      std::panicking::try::do_call
             at /usr/src/rustc-1.42.0/src/libstd/panicking.rs:305
  17: __rust_maybe_catch_panic
             at /usr/src/rustc-1.42.0/src/libpanic_unwind/lib.rs:86
  18: std::panicking::try
             at /usr/src/rustc-1.42.0/src/libstd/panicking.rs:281
      std::panic::catch_unwind
             at /usr/src/rustc-1.42.0/src/libstd/panic.rs:394
      std::rt::lang_start_internal
             at /usr/src/rustc-1.42.0/src/libstd/rt.rs:51
  19: std::rt::lang_start
             at /usr/src/rustc-1.42.0/src/libstd/rt.rs:67
  20: main
  21: __libc_start_main
  22: _start

@extrawurst
Copy link
Owner

hey @guss77 thanks for investigating further, now you run into this bug: #72

please make sure you checkout current master (it was fixed in fdbd87b) and then it should be gone.

@guss77
Copy link

guss77 commented May 22, 2020

After the update, I can no longer crash gitui by resizing the terminal :-)

@extrawurst
Copy link
Owner

wohoooo 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants