mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
bpo-44184: Fix subtype_dealloc() for freed type (GH-26274)
Fix a crash at Python exit when a deallocator function removes the last strong reference to a heap type. Don't read type memory after calling basedealloc() since basedealloc() can deallocate the type and free its memory. _PyMem_IsPtrFreed() argument is now constant.
This commit is contained in:
parent
642fdfdc04
commit
615069eb08
4 changed files with 46 additions and 4 deletions
|
@ -42,7 +42,7 @@ PyAPI_FUNC(int) _PyMem_SetDefaultAllocator(
|
|||
fills newly allocated memory with CLEANBYTE (0xCD) and newly freed memory
|
||||
with DEADBYTE (0xDD). Detect also "untouchable bytes" marked
|
||||
with FORBIDDENBYTE (0xFD). */
|
||||
static inline int _PyMem_IsPtrFreed(void *ptr)
|
||||
static inline int _PyMem_IsPtrFreed(const void *ptr)
|
||||
{
|
||||
uintptr_t value = (uintptr_t)ptr;
|
||||
#if SIZEOF_VOID_P == 8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue