rts: fix Windows megablock allocator

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



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

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

Move test changes to other diff

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

Good catch.

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