microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
10.61k stars 866 forks source link

Fix mi_cfree function missing certain big allocations #915

Open kerambyte opened 4 months ago

kerambyte commented 4 months ago

The way mi_is_in_heap_region is implemented right now (see this code) it is possible to 'miss' certain huge allocations going through mi_cfree. So we either need to update the segment detection code (so that it is not limited to e.g. 2GiB on 32-bit platforms) or use the more expensive mi_check_owned check if we've failed the simpler heap check.

kerambyte commented 4 months ago

Ah, looks like the 32-bit 'address-too-high' issue has been fixed somewhat recently - https://github.com/microsoft/mimalloc/commit/a964322a21907206909798771ab90a9ccf27f8d8

So perhaps this issue is no more. We've seen cases where on 32-bit platforms with really big allocations sometimes we'd get a segment address bigger than 2GiB and then that segment couldn't be 'found'.

I'll leave it to you to decide whether that commit fixes the issue or not, feel free to close this PR if it does. 👍