Workaround for #18623: GHC crashes bc reserves all of limited vmem
Workaround for bug, where GHC would reserve all available process address space when said AS was limited by rlimit, thus causing a crash when a thread gets created.
Fix is as discussed in ticket: Reserve only 2/3 of limit, rounded down to page size multiple. Checks if left over vmem is at least 3*pthread-stack-size bc. in my testing that's how many thread were created. This way we can at least fail early in this case, where later failure is guaranteed.
Tracking: #18623 (closed)
Edited by Benjamin Maurer