Skip to content

Commit

Permalink
pythongh-121460: Skip freeing unallocated arenas (pythongh-121491)
Browse files Browse the repository at this point in the history
`munmap(NULL)` is not noop, like `free(NULL)` is.

Fixes an observed testsuite hang on 32-bit ARM systems.
  • Loading branch information
stefanor authored Jul 10, 2024
1 parent 0177a34 commit a802277
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Objects/obmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a802277

Please sign in to comment.