Segment size calculations may have overflows
The code for segment size calculation (on master) seemed quite sketchy and hard to understand. In particular it lacks overflow checks. I forgot to report the issue when I noticed it, so the details are a bit paged out.
I ended up just rewriting it in my Rust port: https://github.com/Zoxc/fjall/blob/main/src/segment.rs#L549
Thanks! I will take a closer look and improve it.
Btw. thanks for your previous suggestions which have improved mimalloc.
ps. I don't want to derail your current effort to port mimalloc to rust, but recently we improved mimalloc quite a bit in the dev3 branch -- still a bit experimental but it is much simplified : no more segments, and a much cleaner concurrent model. This version shares memory between threads better (on a page level) and may be better suited for rust. It is still a bit in flux though.