RTS: mmap fails on RISC-V with Linux 6.8

Heinrich Schuchardt xypron.glpk at gmx.de
Tue May 27 18:35:36 UTC 2025


The following bug related to the Haskell runtime was reported in Launchpad:

Haskell's default behaviour of using large-address-space is causing 
pandoc to stuck in an infinite loop on QEMU 10 Edit
https://bugs.launchpad.net/ubuntu/+source/ghc/+bug/2111581

The problem seems to relate to the following loop in osReserveHeapMemory():

https://gitlab.haskell.org/ghc/ghc/-/blob/master/rts/posix/OSMem.c?ref_type=heads#L589

According to the mmap() manpage the address passed to the kernel in only 
a hint there is no guarantee that the same address will be used for 
allocation.

As shown in the strace logs attached in Launchpad this code can lead to 
an endless loop when the kernel decides always to return an address 
below 8 GiB.

It might make sense to round up the address to 8 GiB if the returned 
address is below 8 GiB and reduce *len accordingly instead of retrying.

Best regards

Heinrich



More information about the ghc-devs mailing list