index out of bounds: the len is 17526 but the index is 17526
janstarke opened this issue Β· comments
Description
I display a lot of long lines in a table, and in one specific line I receive the following stacktrace:
thread 'main' panicked at /home/jst/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ratatui-0.26.3/src/text/span.rs:380:17:
index out of bounds: the len is 17526 but the index is 17526
stack backtrace:
0: 0x5d67dafc6ad2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hffecb437d922f988
1: 0x5d67dafea28c - core::fmt::write::hd9a8d7d029f9ea1a
2: 0x5d67dafc401f - std::io::Write::write_fmt::h0e1226b2b8d973fe
3: 0x5d67dafc68a4 - std::sys_common::backtrace::print::he907f6ad7eee41cb
4: 0x5d67dafc83cb - std::panicking::default_hook::{{closure}}::h3926193b61c9ca9b
5: 0x5d67dafc8123 - std::panicking::default_hook::h25ba2457dea68e65
6: 0x5d67dafc8a00 - std::panicking::rust_panic_with_hook::h0ad14d90dcf5224f
7: 0x5d67dafc8742 - std::panicking::begin_panic_handler::{{closure}}::h4a1838a06f542647
8: 0x5d67dafc6fa6 - std::sys_common::backtrace::__rust_end_short_backtrace::h77cc4dc3567ca904
9: 0x5d67dafc8474 - rust_begin_unwind
10: 0x5d67daefc3a5 - core::panicking::panic_fmt::h940d4fd01a4b4fd1
11: 0x5d67daefc582 - core::panicking::panic_bounds_check::h9bb22f08a42e1ac8
12: 0x5d67daf3b459 - <ratatui::text::span::Span as ratatui::widgets::WidgetRef>::render_ref::h7d1b172c055f1900
13: 0x5d67daf3ba85 - ratatui::text::line::render_spans::hd7e85f2853a83213
14: 0x5d67daf352ac - <ratatui::text::text::Text as ratatui::widgets::WidgetRef>::render_ref::h9c358aaf6d0b008b
15: 0x5d67daf35007 - <ratatui::text::text::Text as ratatui::widgets::Widget>::render::hc0996a9e0a6c6e20
16: 0x5d67daf33f89 - <ratatui::widgets::table::table::Table as ratatui::widgets::StatefulWidgetRef>::render_ref::h623b727d098fde1a
17: 0x5d67daf32c54 - <ratatui::widgets::table::table::Table as ratatui::widgets::Widget>::render::h37aa979a497a15c4
18: 0x5d67daf145ed - <loghawk::log_view::LogView as ratatui::widgets::StatefulWidget>::render::h10f578de83ffe5ae
19: 0x5d67daf13f9d - loghawk::ui::render::h937c0be71369c4a6
20: 0x5d67daf002ca - ratatui::terminal::terminal::Terminal<B>::draw::h90ac438fdae94eb5
21: 0x5d67daf0393a - loghawk::main::h8d5c194d549e2bae
22: 0x5d67daf02d13 - std::sys_common::backtrace::__rust_begin_short_backtrace::hb20299007b20274a
23: 0x5d67daf05999 - std::rt::lang_start::{{closure}}::hd64e78bfb61006f5
24: 0x5d67dafbe293 - std::rt::lang_start_internal::h103c42a9c4e95084
25: 0x5d67daf03ad5 - main
26: 0x772ba9629d90 - __libc_start_call_main
at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
27: 0x772ba9629e40 - __libc_start_main_impl
at ./csu/../csu/libc-start.c:392:3
28: 0x5d67daefc9c5 - _start
29: 0x0 - <unknown>
thread '<unnamed>' panicked at src/event.rs:65:50:
failed to send tick event: SendError { .. }
stack backtrace:
0: 0x5d67dafc6ad2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hffecb437d922f988
1: 0x5d67dafea28c - core::fmt::write::hd9a8d7d029f9ea1a
2: 0x5d67dafc401f - std::io::Write::write_fmt::h0e1226b2b8d973fe
3: 0x5d67dafc68a4 - std::sys_common::backtrace::print::he907f6ad7eee41cb
4: 0x5d67dafc83cb - std::panicking::default_hook::{{closure}}::h3926193b61c9ca9b
5: 0x5d67dafc8123 - std::panicking::default_hook::h25ba2457dea68e65
6: 0x5d67dafc8a00 - std::panicking::rust_panic_with_hook::h0ad14d90dcf5224f
7: 0x5d67dafc8742 - std::panicking::begin_panic_handler::{{closure}}::h4a1838a06f542647
8: 0x5d67dafc6fa6 - std::sys_common::backtrace::__rust_end_short_backtrace::h77cc4dc3567ca904
9: 0x5d67dafc8474 - rust_begin_unwind
10: 0x5d67daefc3a5 - core::panicking::panic_fmt::h940d4fd01a4b4fd1
11: 0x5d67daefc813 - core::result::unwrap_failed::h5119205a73b72b0d
12: 0x5d67daf08677 - std::sys_common::backtrace::__rust_begin_short_backtrace::h99cfb0d3842dd678
13: 0x5d67daf0e160 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h2631825934d89004
14: 0x5d67dafccb15 - std::sys::pal::unix::thread::Thread::new::thread_start::h420dad5cf01a9f35
15: 0x772ba9694ac3 - start_thread
at ./nptl/pthread_create.c:442:8
16: 0x772ba9726850 - __GI___clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
17: 0x0 - <unknown>
To Reproduce
I'm trying to display a large csv file, where one line accidently contains some Unicode Left-Right-Marks (U+200E), which seems to cause the issue. I'm not able to construct a MWE for now
Expected behavior
ratatui
should not panic
Screenshots
Environment
- OS: Linux
- Terminal Emulator: screen-256color
- Font: Hack Nerd Font Mono
- Crate version: 0.26.3
- Backend: default (ncurses)
Additional context
Thanks for the bug report. I think the stacktrace will probably be enough to find the error.
Incidentally, have you considered whether it might make sense to add your app's functionality (pinning the first column) to https://github.com/YS-L/csvlens instead of building it out into into another app?
Why doesn't this stacktrace have line numbers?
12: 0x5d67daf3b459 - <ratatui::text::span::Span as ratatui::widgets::WidgetRef>::render_ref::h7d1b172c055f1900
13: 0x5d67daf3ba85 - ratatui::text::line::render_spans::hd7e85f2853a83213
14: 0x5d67daf352ac - <ratatui::text::text::Text as ratatui::widgets::WidgetRef>::render_ref::h9c358aaf6d0b008b
15: 0x5d67daf35007 - <ratatui::text::text::Text as ratatui::widgets::Widget>::render::hc0996a9e0a6c6e20
16: 0x5d67daf33f89 - <ratatui::widgets::table::table::Table as ratatui::widgets::StatefulWidgetRef>::render_ref::h623b727d098fde1a
17: 0x5d67daf32c54 - <ratatui::widgets::table::table::Table as ratatui::widgets::Widget>::render::h37aa979a497a15c4
release mode probably?
Thanks for the bug report. I think the stacktrace will probably be enough to find the error.
Incidentally, have you considered whether it might make sense to add your app's functionality (pinning the first column) to https://github.com/YS-L/csvlens instead of building it out into into another app?
Thank you for this hint, I didn't know this tool until now. I tried, but I think there would be more to change then pinning the first column. csvlens
breaks csv columns which contain JSON data. This helps reading files, but it is not good for forensic work. Furthermore, I want to highlight lines or columns based on regular expressions. When we do forensic investigation, we often read thousands of log lines per day, to find things that should not be there. I want the tool to support this work.
However, I will include csvlens
in my future work, because until now I used xsv table | less -S
; while csvlens
looks much better. π
csvlens breaks csv columns which contain JSON data. This helps reading files, but it is not good for forensic work. Furthermore, I want to highlight lines or columns based on regular expressions.
Both of these seem like reasonable features to implement in csvlens (not breaking json data and highlighting lines or columns)
You're right. Let me think about this
Also, pinning the first n columns would also make a good feature there too. I don't want to discourage you from writing an app like this if you want to, but given a choice of 1 excellent app or 2 good ones, I'd generally take the first choice.
This bug is explicitly hit when the zero width character is at the end of the rendering area. Give the fix in #1165 a try (with a patch dependency pointing at the PR) and let me know if that fixes your issue. I'm about 95% certain that will fix the bug you're seeing, but If it doesn't, can you please provide a debug stack trace which includes the relevant line numbers.
Fixed by #1165
Thanks a lot for your work π