ctm / mb2-doc

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

table split panicked #1248

Closed ctm closed 9 months ago

ctm commented 9 months ago

Fix the bug that caused the panic today when we were playing SOHE.

2023-11-29T00:07:02.099345271Z messages: []
2023-11-29T01:19:20.900394631Z thread '<unnamed>' panicked at mb2/src/tournament/late_registration/table_splitter.rs:248:13:
2023-11-29T01:19:20.900473983Z attempt to subtract with overflow
2023-11-29T01:19:20.900483554Z stack backtrace:
[...]
2023-11-29T01:19:20.910560818Z   12:     0x5654a8fc12a2 - mb2::tournament::late_registration::table_splitter::ToMove::from_running_event::h1c00585dd8d78350
ctm commented 9 months ago

This death is trivially reproducible. It's in a section of code that I didn't particularly like when I wrote it and that I like even less, now.

I'm seriously considering completely refactoring, by writing a little test project and either add exhaustive testing for some largish number of tables (e.g., 100) or random testing.

Before I do that, I'll look into fixing the existing code, though, because I don't want any crashes in the meantime.

ctm commented 9 months ago

I've deployed a stop-gap. It doesn't panic when a 7-seated table is split, but the split leaves 5 and starts a new table of 3, which is broken. However, I'm definitely replacing the code that does that with entirely new code that is much simpler.

ctm commented 9 months ago

I've rewritten the troublesome section and the new section is so clean that I'm not adding any extra testing. I'll deploy after this evening's game.