fix osReserveHeapMemory block alignment
authorSergei Trofimovich <slyfox@gentoo.org>
Wed, 18 Jul 2018 21:36:58 +0000 (22:36 +0100)
committerGianfranco Costamagna <locutusofborg@debian.org>
Thu, 28 Feb 2019 14:18:49 +0000 (14:18 +0000)
commiteb457bd25f49cf5b4f3c11e2c06a71aa00a75c74
treea0b78e9b8e5b89f1ba73d510fc5814bf80a7d52c
parent219dfd2b9241bbb53f43bbb9253e44c96c87bb6e
fix osReserveHeapMemory block alignment

fix osReserveHeapMemory block alignment

Before the change osReserveHeapMemory() attempted
to allocate chunks of memory via osTryReserveHeapMemory()
not multiple of MBLOCK_SIZE in the following fallback code:

```
    if (at == NULL) {
        *len -= *len / 8;
```

and caused assertion failure:

```
$ make fulltest TEST=T11607 WAY=threaded1
T11607: internal error: ASSERTION FAILED: file rts/posix/OSMem.c, line 457
    (GHC version 8.7.20180716 for riscv64_unknown_linux)

```

The change applies alignment mask before each MBLOCK allocation attempt
and fixes WAY=threaded1 test failures on qemu-riscv64.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Test Plan: run 'make fulltest WAY=threaded1'

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4982

Gbp-Pq: Name e175aaf6918bb2b497b83618dc4c270a0d231a1c.patch
rts/posix/OSMem.c