mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 08:33:12 -05:00
On Linux, glibc maps the stack of every guest thread near the top of the host address space (around 0x7fff00000000). On the console, application stacks lie inside the application area below 0xFC00000000, and guest code relies on that: ChakraCore's garbage collector indexes a 4 MiB table with address >> 18, so it only covers addresses below 1 TiB and reports Js::OutOfMemoryException for a stack above it. Map each guest thread's stack with DoMapAnon, which allocates from the guest arena, behind a PROT_NONE guard page, and pass it to pthread_attr_setstack. The stack is freed after a join; the stack of a detached thread is freed once its host thread is gone from /proc/self/task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>