agg icon indicating copy to clipboard operation
agg copied to clipboard

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

Open hartwork opened this issue 2 years ago • 1 comments

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

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) — https://github.com/asciinema/agg/commit/ec02812e

Additional context Please see description

hartwork avatar Nov 27 '23 01:11 hartwork

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.

ku1ik avatar Oct 27 '24 10:10 ku1ik

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

hartwork avatar Nov 13 '24 15:11 hartwork

@ku1ik any news?

hartwork avatar Jul 12 '25 23:07 hartwork

@ku1ik thank you! 👍

hartwork avatar Oct 22 '25 15:10 hartwork

Just released 1.7 with the fix: https://github.com/asciinema/agg/releases/tag/v1.7.0

ku1ik avatar Oct 22 '25 16:10 ku1ik