| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Other than the stylistic stuff @maurycy pointed out, I think this looks fine.
Sorry, something went wrong.
The original fix rounded datastack chunk allocations in pystate.c so that _PyObject_VirtualFree() would receive the full huge page mapping size. Change direction and move that logic into _PyObject_VirtualAlloc() and _PyObject_VirtualFree() instead. The key invariant is that munmap() must see the full mapped size, so alloc and free now apply the same platform-specific rounding in the allocator layer. This keeps _PyStackChunk bookkeeping in requested-size units, avoids a hardcoded 2 MB assumption, and also covers other small virtual-memory users such as the JIT tracer state allocation in optimizer.c.
|
I changed direction from the pystate.c-local roundup to an allocator-level fix. The important invariant here is that munmap() must always see the full mapped size, so I moved the rounding into _PyObject_VirtualAlloc() / _PyObject_VirtualFree() to keep alloc/free symmetric. That also covers the JIT tracer path instead of fixing only the datastack caller. |
Sorry, something went wrong.
…hon#147963) Fix huge page leak in datastack chunk allocator The original fix rounded datastack chunk allocations in pystate.c so that _PyObject_VirtualFree() would receive the full huge page mapping size. Change direction and move that logic into _PyObject_VirtualAlloc() and _PyObject_VirtualFree() instead. The key invariant is that munmap() must see the full mapped size, so alloc and free now apply the same platform-specific rounding in the allocator layer. This keeps _PyStackChunk bookkeeping in requested-size units, avoids a hardcoded 2 MB assumption, and also covers other small virtual-memory users such as the JIT tracer state allocation in optimizer.c.
| Back | FazBrowse Home | New Git URL |
The datastack chunk allocator (allocate_chunk in pystate.c) and other
small virtual-memory users such as the JIT tracer allocate through
_PyObject_VirtualAlloc() using the logical requested size. When huge pages
are enabled, the arena allocator may round those mappings up to the platform
huge page size, so freeing with the smaller requested size can make
munmap() fail with EINVAL and leak the mapping.
This change moves the rounding logic into _PyObject_VirtualAlloc() /
_PyObject_VirtualFree() so allocation and free always agree on the full
mapped size. Keeping it in the allocator layer also avoids a hardcoded 2 MB
assumption in pystate.c and fixes the JIT tracer allocation path at the
same time.