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

[Bug]: atuin stats panics when faced with unusual string in history #1882

Open
1 task done
HerbCSO opened this issue Mar 14, 2024 · 4 comments
Open
1 task done

[Bug]: atuin stats panics when faced with unusual string in history #1882

HerbCSO opened this issue Mar 14, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@HerbCSO
Copy link

HerbCSO commented Mar 14, 2024

What did you expect to happen?

No panic! ;]

What happened?

When running atuin stats it panics with:

❯ RUST_BACKTRACE=1 atuin stats
thread 'main' panicked at atuin/src/command/client/stats.rs:56:41:
begin <= end (1 <= 0) when slicing `| awk '{print $1}' | R --no-echo -e 'x <- scan(file="stdin", quiet=TRUE); summary(x)'`
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
   4: atuin::command::client::stats::compute_stats
   5: atuin::command::client::Cmd::run_inner::{{closure}}
   6: tokio::runtime::scheduler::current_thread::Context::enter
   7: tokio::runtime::context::set_scheduler
   8: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
   9: tokio::runtime::context::runtime::enter_runtime
  10: tokio::runtime::runtime::Runtime::block_on
  11: atuin::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Now that string | awk '{print $1}' | R --no-echo -e 'x <- scan(file="stdin", quiet=TRUE); summary(x)' is actually in my history like that (it's the "entire" command), so obviously some copy-pasta failure on my part, but I don't think it should make atuin panic (maybe due to starting with a |?).

Atuin doctor output

Atuin Doctor
Checking for diagnostics


Please include the output below with any bug reports or issues

atuin:
  version: 18.1.0
  sync:
    cloud: false
    records: true
    auto_sync: true
    last_sync: 2024-03-14 18:05:58.081633 +00:00:00
shell:
  name: zsh
  plugins:
  - atuin
system:
  os: Darwin
  arch: x86_64
  version: 14.3.1
  disks:
  - name: Macintosh HD
    filesystem: apfs
  - name: Macintosh HD
    filesystem: apfs

Code of Conduct

  • I agree to follow this project's Code of Conduct
@HerbCSO HerbCSO added the bug Something isn't working label Mar 14, 2024
@pjjw
Copy link

pjjw commented Mar 24, 2024

seconding this- here's another fun string this happens with.

$ RUST_BACKTRACE=1 atuin stats
thread 'main' panicked at atuin/src/command/client/stats.rs:56:41:
begin <= end (1 <= 0) when slicing `|_|  |____||___||_|  |_|  |___||_|_`
stack backtrace:
   0:        0x1054a29d0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h61949099c17bb561
   1:        0x1054ca8e0 - core::fmt::write::he0c0819610fe7c82
   2:        0x105487c8c - std::io::Write::write_fmt::h14dadda6958822c3
   3:        0x1054a2824 - std::sys_common::backtrace::print::h10166cbeffac9d38
   4:        0x1054a3360 - std::panicking::default_hook::{{closure}}::hfec7fca779e11f3b
   5:        0x1054a30e0 - std::panicking::default_hook::h26402d2c6670ffd0
   6:        0x1054a39d4 - std::panicking::rust_panic_with_hook::hb00dd38969b5a277
   7:        0x1054a378c - std::panicking::begin_panic_handler::{{closure}}::hc86edf66ba485638
   8:        0x1054a2c04 - std::sys_common::backtrace::__rust_end_short_backtrace::h24f57ebe971b5eac
   9:        0x1054a3514 - _rust_begin_unwind
  10:        0x1055123e8 - core::panicking::panic_fmt::h21b3a72f47844886
  11:        0x1054c6c10 - core::str::slice_error_fail_rt::h0bcfaeca513f69c4
  12:        0x105512790 - core::str::slice_error_fail::h2e034b398f7b75a7
  13:        0x104c3f69c - atuin::command::client::stats::compute_stats::h309a358b9b61ecd5
  14:        0x104a24714 - atuin::command::client::Cmd::run_inner::{{closure}}::h4a9567b4490695de
  15:        0x104b13448 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::h351c1c892460edf6
  16:        0x104c38318 - tokio::runtime::context::runtime::enter_runtime::hef50c501bad43a82
  17:        0x104b6e14c - tokio::runtime::runtime::Runtime::block_on::h7d3459fe69753074
  18:        0x104bd38a4 - atuin::command::client::Cmd::run::h588a5ab129b29fa6
  19:        0x104c400a4 - atuin::command::AtuinCmd::run::hf663edac3a0da924
  20:        0x104bd3d70 - atuin::main::h61cb3fcec8322f37
  21:        0x104b96218 - std::sys_common::backtrace::__rust_begin_short_backtrace::he76aba5053fdcc16
  22:        0x104c242b8 - std::rt::lang_start::{{closure}}::h024e6bed810fd961
  23:        0x1054a3400 - std::panicking::try::ha883230fd73a158c
  24:        0x105485fc0 - std::rt::lang_start_internal::ha86617696da0c619
  25:        0x104bd8c0c - _main

installed via nixpkgs/nix-darwin. atuin doctor output:

atuin:
  version: 18.1.0
  sync:
    cloud: false
    records: false
    auto_sync: true
    last_sync: 2024-03-24 19:14:04.454307 +00:00:00
shell:
  name: zsh
  plugins:
  - atuin
system:
  os: Darwin
  arch: arm64
  version: '14.4'
  disks:
  - name: Macintosh HD
    filesystem: apfs
  - name: Macintosh HD
    filesystem: apfs

@bdashrad
Copy link

this helped me track down and a similar panic, with | landscape as a history entry. I deleted the entry in atuin to fix my stats output.

@zellyn
Copy link

zellyn commented Apr 19, 2024

Got something very similar:

atuin stats       
thread 'main' panicked at atuin/src/command/client/stats.rs:56:41:
begin <= end (1 <= 0) when slicing `| wc -l`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It would be helpful if it printed the entire command that caused the problem, so I could delete it.

@rudygt
Copy link

rudygt commented May 14, 2024

something similar

image

RUST_BACKTRACE=full atuin stats thread 'main' panicked at atuin/src/command/client/stats.rs:56:41: begin <= end (1 <= 0) when slicing| HTTPCode=%{http_code}\n\n" stack backtrace: 0: 0x562b9d838c96 - <unknown> 1: 0x562b9d868f20 - <unknown> 2: 0x562b9d834f6f - <unknown>

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

5 participants