jwt-ui icon indicating copy to clipboard operation
jwt-ui copied to clipboard

Crashing on Manual Refresh

Open cyeganeh01248 opened this issue 1 year ago • 2 comments

Describe the bug The application has a problem and crashes when pressing Ctrl + r in the main app

To Reproduce Steps to reproduce the behavior or a screencast

  1. Open jwtui
  2. Press Ctrl + r
  3. See error

Expected behavior Manual refresh of application

Screenshots CleanShot 2024-05-01 at 13 00 46@2x

Desktop (please complete the following information):

  • OS and OS version: macOs 14.4.1
  • Terminal name and version: iTerm2 3.4.23
  • Shell name and version: zsh
  • jwt-ui version: 1.1.0

cyeganeh01248 avatar May 01 '24 17:05 cyeganeh01248

This will make the (zsh) terminal unusable too, since it will write scroll-characters. Using zsh 5.8 (x86_64-ubuntu-linux-gnu) with the main branch of the jwt-ui on Ubuntu 20.04 I can reproduce the behavior.

thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', src/app/models.rs:143:16
   0: jwtui::panic_hook
             at /home/developer/Projects/Rust/jwt-ui/src/main.rs:191:44
   1: jwtui::main::{{closure}}
             at /home/developer/Projects/Rust/jwt-ui/src/main.rs:59:5
   2: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/alloc/src/boxed.rs:2029:9
      std::panicking::rust_panic_with_hook
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:785:13
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:659:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:171:18
   5: rust_begin_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
   6: core::panicking::panic_fmt
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
   7: core::panicking::panic_bounds_check
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:208:5
   8: <usize as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/slice/index.rs:255:10
   9: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/slice/index.rs:18:9
      <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/alloc/src/vec/mod.rs:2771:9
  10: jwtui::app::models::BlockState::get_active_block
             at /home/developer/Projects/Rust/jwt-ui/src/app/models.rs:143:16
  11: jwtui::ui::decoder::draw_token_block
             at /home/developer/Projects/Rust/jwt-ui/src/ui/decoder.rs:47:6
  12: jwtui::ui::decoder::draw_left_side
             at /home/developer/Projects/Rust/jwt-ui/src/ui/decoder.rs:29:3
  13: jwtui::ui::decoder::draw_decoder
             at /home/developer/Projects/Rust/jwt-ui/src/ui/decoder.rs:19:3
  14: jwtui::ui::draw
             at /home/developer/Projects/Rust/jwt-ui/src/ui/mod.rs:66:7
  15: jwtui::start_ui::{{closure}}
             at /home/developer/Projects/Rust/jwt-ui/src/main.rs:132:23
  16: ratatui::terminal::terminal::Terminal<B>::draw
             at /home/developer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ratatui-0.26.2/src/terminal/terminal.rs:269:9
  17: jwtui::start_ui
             at /home/developer/Projects/Rust/jwt-ui/src/main.rs:132:5
  18: jwtui::main
             at /home/developer/Projects/Rust/jwt-ui/src/main.rs:73:5
  19: core::ops::function::FnOnce::call_once
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:250:5
  20: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:155:18
  21: std::rt::lang_start::{{closure}}
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:166:18
  22: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:554:40
      std::panicking::try
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:518:19
      std::panic::catch_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:148:48
      std::panicking::try::do_call
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:554:40
      std::panicking::try
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:518:19
      std::panic::catch_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:148:20
  23: std::rt::lang_start
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:165:17
  24: main
  25: __libc_start_main
             at /build/glibc-e2p3jK/glibc-2.31/csu/../csu/libc-start.c:308:16
  26: _start

Scroll characters after jwt-ui died (ctrl+c wont help): image

tolik518 avatar May 06 '24 08:05 tolik518

I saw the scroll character issues and I thought I fixed it by disabling mouse capture

deepu105 avatar May 20 '24 07:05 deepu105

Ok seems like I was not doing DisableMouseCapture on panic hook

deepu105 avatar May 23 '24 16:05 deepu105