outbrain / fwumious_wabbit

Fwumious Wabbit, fast on-line machine learning toolkit written in Rust
Other
133 stars 19 forks source link

discarding of temporary pointer as it may become invalid in case the vector is reallocated #39

Closed yonatankarni closed 3 years ago

yonatankarni commented 3 years ago

while investigating some FW crashes due to segmentation fault, caused by malloc trying to allocate a block and complaining that the block CRC isn't the same as when it was freed, I ran valgrind (on our reproducible setup offline) and got a hint that something bad is going on in some lines in parser.rs the only thing I could imagine happening is the "buf" pointer somehow becoming invalid, it seems this can happen if the output_buffer vec grows and is reallocated. got rid of it - and the valgrind complaints went away, as well as the crashes. still not sure exactly about the scenario though - because the vector is preallocated generously on startup, so we might want to continue looking into the input as there may be something fishy going on there. WDYT?

andraztori commented 3 years ago

Wow, what a search for the bug. Indeed there it is. However here's somewhat less error prone fix: https://github.com/outbrain/fwumious_wabbit/pull/40