LaihoE / demoparser

Counter-Strike 2 replay parser for Python and JavaScript
MIT License
249 stars 29 forks source link

Rust panic #11

Open osztenkurden opened 10 months ago

osztenkurden commented 10 months ago

Hey,

I'm getting error originating from Rust while parsing specific demo:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Literal { len: 28, src_len: 89138, dst_len: 0 }', demoparser\src\parser\src\parser.rs:72:93
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm doing only parseHeader(demoPath), all other demos I've tested work fine so far.

Demo link: https://drive.google.com/file/d/1bQ15cGalTWjIglCB2MCrVixK1IlBB5a_/view?usp=sharing

LaihoE commented 10 months ago

hmm interesting was able to reproduce. Is there anything special about the demo? The error seems to be happening in an odd place.

LaihoE commented 10 months ago

Anyway I've removed the panic and should now raise a proper error. Will be part of next release. I'm still curious tho on why that demo fails.

osztenkurden commented 10 months ago

From my side it looks like normal demo, so also not sure why it fails

LaihoE commented 10 months ago

The demo runs fine in the official demo viewer so something seems to be wrong.

LaihoE commented 10 months ago

After some investigation there seems to be a corrupt packet at tick 46095. Markus parser fails at the same tick. If I skip this tick the rest of the demo seems to work just fine. This leads us to a tricky question: What should be done in this situation? Should the parser raise an error or something else? A corrupt packet can have unexpected consequences later on in the demo... But in this situation It's almost certainly fine sooo...

osztenkurden commented 10 months ago

Perhaps custom event "error" or something, so after parsing it would be possible to check for "error" events, and decide what to do with the result?