Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
runtime: stackFromSystem can leak memory or leave unmapped memory behind #17289
When stackFromSystem = 1, the stack allocation size is rounded to the nearest page size:
...however, that rounded size is not returned to/used by the caller of stackalloc(), so when a stackfree() is later done:
We'll either set less than the actual bytes allocated for faulted access, or fail to free/unmap all of the memory.
I suspect this isn't generally noticed on architectures that use a pagesize of 4096, since when we do a stackalloc, we'll typically do it for at least 4096, which is the nearest page size, so it usually works as expected.
As such, I suspect this is generally the most noticeable on mips64, ppc64, arm, arm64, etc.
This was discovered while working on the sparc64 port since the DefaultPhysPageSize is 8192.