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

agg panics at runtime at src/buffer.rs:80:13 of AVT: index out of bounds: the len is 0 but the index is 0 #62

Open
hartwork opened this issue Nov 27, 2023 · 2 comments

Comments

@hartwork
Copy link

Describe the bug
Hi! Thanks for making asciinema and agg and sharing them as Software Libre! 🙏

I recorded some cast file with asciinema 2.3.0, fed it to agg and it panicked. Note the "width": 0, "height": 0, those were produced by asciinema from…

export COLUMNS=90
export ROWS=20

…in the environment at recording time.

So now for the crashing agg:

# RUST_BACKTRACE=1 ~/.cargo/bin/agg ~/Desktop/bug.cast.txt out.gif |& sed "s,${USER},user123,"
thread 'main' panicked at /home/user123/.cargo/git/checkouts/avt-68339788ba7d673e/28aed2b/src/buffer.rs:80:13:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
   1: core::panicking::panic_fmt
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
   2: core::panicking::panic_bounds_check
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:162:5
   3: <avt::terminal::Terminal as avt::parser::Executor>::print
   4: avt::vt::Vt::feed_str
   5: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
   6: std::thread::scoped::scope
   7: agg::run
   8: agg::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
4 / 4 [=====================================================] 100.00 % 221.70/s 

# sed -n '79,81p' ~/.cargo/git/checkouts/avt-*/*/src/buffer.rs
    pub fn print(&mut self, (col, row): VisualPosition, cell: Cell) {
        self[row].print(col, cell);
    }

To Reproduce

  1. Download the attached cast produced by asciinema 2.3.0
  2. Run ~/.cargo/bin/agg bug.cast.txt out.gif
  3. See agg panic

Expected behavior
No panic

Versions:

  • OS: Linux
  • agg: v1.4.3 (https://github.com/asciinema/agg#ec02812e) — ec02812e

Additional context
Please see description

@ku1ik
Copy link
Contributor

ku1ik commented Oct 27, 2024

So the main problem is the recorder put 0x0 size in the cast file, which we should prevent from happening in the first place. But I think it's a good idea to add a check here in agg and bail if any of the dimensions is lower non-positive.

@hartwork
Copy link
Author

But I think it's a good idea to add a check here in agg and bail if any of the dimensions is lower non-positive.

@ku1ik yes please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants