benfred / py-spy

Sampling profiler for Python programs
MIT License
12.87k stars 431 forks source link

attempt to subtract with overflow in console_viewer.rs #649

Open freedge opened 10 months ago

freedge commented 10 months ago

noticed when resizing the terminal (either with tmux or with resizing my terminal window), py-spy crashes with

thread 'main' panicked at src/console_viewer.rs:261:52:
attempt to subtract with overflow
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: py_spy::console_viewer::ConsoleViewer::display
             at ./py-spy/src/console_viewer.rs:261:52
   4: py_spy::console_viewer::ConsoleViewer::increment_common
             at ./py-spy/src/console_viewer.rs:357:13
   5: py_spy::console_viewer::ConsoleViewer::increment
             at ./py-spy/src/console_viewer.rs:128:9
   6: py_spy::sample_console
             at ./py-spy/src/main.rs:80:9
   7: py_spy::run_spy_command
             at ./py-spy/src/main.rs:381:13
   8: py_spy::pyspy_main
             at ./py-spy/src/main.rs:413:9
   9: py_spy::main
             at ./py-spy/src/main.rs:488:23
  10: core::ops::function::FnOnce::call_once
             at /builddir/build/BUILD/rustc-1.73.0-src/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

when there are not enough lines for py-spy to draw itself