rts: fix Windows megablock allocator
ClosedPublic

Authored by Phyx on Tue, Nov 20, 5:48 PM.

Details

Summary

The megablock allocator does not currently check that after aligning the free
region if it still has enough space to actually do the allocation.

This causes it to return a memory region which it didn't fully allocate
itself. Even worse, it can cause it to return a block with a region
that will be present in two allocation pools.

This causes if you're lucky an error from the OS that you're committing
memory that has never been reserved, or causes random heap corruption.

This change makes it consider the alignment as well.

Test Plan

./validate , testcase testmblockalloc

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
Phyx created this revision.Tue, Nov 20, 5:48 PM
Phyx updated this revision to Diff 18798.Tue, Nov 20, 6:12 PM

Move test changes to other diff

simonmar accepted this revision.Thu, Nov 22, 5:51 AM

Good catch.

This revision is now accepted and ready to land.Thu, Nov 22, 5:51 AM
This revision was automatically updated to reflect the committed changes.