Skip to content

vmem limit causes GHC startup failure

Summary

When setting a virtual memory limit of <1.3GB, GHC wont start with the error:

ghc: failed to create OS thread: Cannot allocate memory

This has led to broken Haskell support in Compiler Explorer ("godbolt"):

https://github.com/compiler-explorer/compiler-explorer/issues/1412

This is probably due to #9706 (closed) "New block-structured heap organization for 64-bit" Other related issues:
#14193 (closed) "Add RTS flag to disable 1TB address space allocation"
#8604 "Some stack/vmem limits (ulimit) combinations causing GHC to fail" \

Steps to reproduce

In a new terminal:

ulimit -v 1258292

Then try to run ghc. In a different, new, terminal, try 1.3GB:

ulimit -v 1363148

Then run ghc which should work.

Or see failure in Compiler Explorer: https://gcc.godbolt.org/z/zKs4a6

Environment

  • GHC version used: 8.6.5, (8.8.3 through stack), Compiler Explorer uses 8.6.1 and 8.6.2

Optional:

  • Operating System: Ubuntu 20.04, Kernel 5.8.0-050800-generic
  • System Architecture: AMD64 (AMD Ryzen 7 4700U)
Edited by Benjamin Maurer
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information