]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-144319: Fix huge page leak in datastack chunk allocator (#147963)
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Sun, 5 Apr 2026 15:29:38 +0000 (16:29 +0100)
committerGitHub <noreply@github.com>
Sun, 5 Apr 2026 15:29:38 +0000 (16:29 +0100)
commit77fc2f5a5e4ca92c609b87425a4080b71c5fa188
tree479f6035005fd663c4bedf01a32ae037b1c6e73e
parent668c5723ebf30441961fceb7795566c17222c04b
gh-144319: Fix huge page leak in datastack chunk allocator (#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.
Include/internal/pycore_obmalloc.h
Misc/NEWS.d/next/Core_and_Builtins/2026-04-01-12-52-31.gh-issue-144319.iZk4hs.rst [new file with mode: 0644]
Objects/obmalloc.c