summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorStefano Rivera <stefano@rivera.za.net>2024-07-10 16:40:55 (GMT)
committerGitHub <noreply@github.com>2024-07-10 16:40:55 (GMT)
commita802277914405786f6425f2776605c44bd407fc0 (patch)
treef089f908c1f00c43e9bc246eb1dc68683ec2d3ef /Objects
parent0177a343353d88ca8475dccabf6e98e164abb0e8 (diff)
downloadcpython-a802277914405786f6425f2776605c44bd407fc0.zip
cpython-a802277914405786f6425f2776605c44bd407fc0.tar.gz
cpython-a802277914405786f6425f2776605c44bd407fc0.tar.bz2
gh-121460: Skip freeing unallocated arenas (gh-121491)
`munmap(NULL)` is not noop, like `free(NULL)` is. Fixes an observed testsuite hang on 32-bit ARM systems.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/obmalloc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index d033e2b..a6a7180 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -386,8 +386,16 @@ _PyMem_ArenaFree(void *Py_UNUSED(ctx), void *ptr,
)
{
#ifdef MS_WINDOWS
+ /* Unlike free(), VirtualFree() does not special-case NULL to noop. */
+ if (ptr == NULL) {
+ return;
+ }
VirtualFree(ptr, 0, MEM_RELEASE);
#elif defined(ARENAS_USE_MMAP)
+ /* Unlike free(), munmap() does not special-case NULL to noop. */
+ if (ptr == NULL) {
+ return;
+ }
munmap(ptr, size);
#else
free(ptr);