Stack overflows should not kill the process
When Loko allocates an internal process, it assigns a static part of the address space to that process's stack. At the end of the stack there is a guard page and if the process hits it then there's a page fault which is not handled gracefully.
I see a few possible ways forward:
- Handle the page fault gracefully (raise an exception). Raising an exception is slightly complicated by the fact that the process is out of stack.
- Allocate more stack memory. We could use segmented stacks like Chez (there should be a paper about this). There are interactions with the GC and call/cc.
- Assign "enough" address space to the stack that they "never" overflow.
- Kill only the internal process that had a stack overflow.
Another consideration about stacks is that the pages backing them up probably should be released during a GC (e.g. madvise with MADV_DONTNEED).