mimblewimble / grin

Minimal implementation of the Mimblewimble protocol.
https://grin.mw/
Apache License 2.0
5.04k stars 990 forks source link

Panic in `cursive` dependency #3595

Closed trevyn closed 3 years ago

trevyn commented 3 years ago

Reported at: https://forum.grin.mw/t/failed-to-start-a-new-grin-node/8413

I filed https://github.com/gyscos/cursive/pull/565 (xposted below) and will move this forward when that gets merged and published.

Hi! We received a report of a panic in cursive:

thread ‘main’ panicked at ‘attempt to calculate the remainder with a divisor of zero’: /home/cephd/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/cursive-0.15.0/src/backends/curses/mod.rs:93

It looks like it's due to this line:

Color::Light(BaseColor::Black) => 8 % max_colors,

It appears that the max_colors value is being sourced from ncurses::COLORS(), which I can only assume is returning 0 for whatever reason.

Since the rest of the code looks as though it is written to assume at least 8 colors, this PR puts a lower bound of 8 on max_colors to prevent this panic.

Also happy to implement a different solution if you prefer!

quentinlesceller commented 3 years ago

Nice catch @trevyn !

quentinlesceller commented 3 years ago

Looks like it is now merge. Closing.