Commit a8bc7a4
committed
[AI generated] fix: Clamp GPU graph widths to prevent crash on small terminals
When many GPUs are present and the terminal is small, the GPU graph
width calculations in Cpu::draw init_graphs and draw_graphs can
produce negative values. This causes std::out_of_range from the
Draw::Graph constructor, surfacing as "Exception in runner thread ->
Cpu:: -> deque".
The root cause is the remainder-distribution formula for the last GPU
graph: graph_width + graph_default_width%graph_width - gpus.size() + 1
which underflows when gpus.size() exceeds the available remainder plus
graph_width. The per-GPU graph_width itself can also go below 1 when
graph_default_width is small relative to gpu_draw_count.
Clamp both graph_width and the last-GPU width to a minimum of 1, and
clamp the cursor movement arguments in draw_graphs to prevent negative
Mv::l and Mv::r values.1 parent 6462ebc commit a8bc7a4
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
| 627 | + | |
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
640 | | - | |
| 640 | + | |
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
| |||
792 | 792 | | |
793 | 793 | | |
794 | 794 | | |
795 | | - | |
796 | | - | |
| 795 | + | |
| 796 | + | |
797 | 797 | | |
798 | 798 | | |
799 | 799 | | |
| |||
0 commit comments