ctm / mb2-doc

Mb2, poker software
https://devctm.com
7 stars 2 forks source link

failing demo can cause panic #1433

Closed ctm closed 1 month ago

ctm commented 1 month ago

Fix so that if a demo fails to start, we call log::error! instead of panicking.

I just had this happen:

thread 'main' panicked at mb2/src/mb2/pen.rs:82:32:
shouldn't get here
stack backtrace:
   0:        0x10e3edc63 - std::backtrace_rs::backtrace::libunwind::trace::h5bfe4001d39ebff3
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
...
  16:        0x10d378e73 - mb2::mb2::pen::Pen::act::h401b81e42dcbb2fc
                               at /Users/ctm/poker/rust/poker/mb2/src/mb2/pen.rs:82:32
  17:        0x10d0fdba4 - mb2::mb2::nick_mapper::NickMapper::process_pen_user_request::h56b755c313dd06ab
                               at /Users/ctm/poker/rust/poker/mb2/src/mb2/nick_mapper.rs:848:21
...

The issue is that NickMapper::pre_processed for a StartDemo returns false if the demo fails to start, which means the StartDemo is passed into Pen::act, which is wrong, so act panics.

I should fix the panic to be a bit more descriptive (not that it mattered here), but more importantly, a failure to start a demo should be logged via error! and pre_processed should return true. Oh, I should also look into the error that prevented the demo from starting. I believe it is related to restarting mb2 in a weird state, but that could be a weird state that would be possible to get into after an upgrade (at least until I can rule that out).

ctm commented 1 month ago

Fixed. Deploying now. I'll make a separate issue for the "weird state" that was indeed related to a restart.