mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-116008: Detect freed thread state in faulthandler (#141988)
Add _PyMem_IsULongFreed() function.
This commit is contained in:
parent
83d8134c5b
commit
d5d9e89dde
2 changed files with 40 additions and 4 deletions
|
|
@ -70,6 +70,27 @@ static inline int _PyMem_IsPtrFreed(const void *ptr)
|
|||
#endif
|
||||
}
|
||||
|
||||
// Similar to _PyMem_IsPtrFreed() but expects an 'unsigned long' instead of a
|
||||
// pointer.
|
||||
static inline int _PyMem_IsULongFreed(unsigned long value)
|
||||
{
|
||||
#if SIZEOF_LONG == 8
|
||||
return (value == 0
|
||||
|| value == (unsigned long)0xCDCDCDCDCDCDCDCD
|
||||
|| value == (unsigned long)0xDDDDDDDDDDDDDDDD
|
||||
|| value == (unsigned long)0xFDFDFDFDFDFDFDFD
|
||||
|| value == (unsigned long)0xFFFFFFFFFFFFFFFF);
|
||||
#elif SIZEOF_LONG == 4
|
||||
return (value == 0
|
||||
|| value == (unsigned long)0xCDCDCDCD
|
||||
|| value == (unsigned long)0xDDDDDDDD
|
||||
|| value == (unsigned long)0xFDFDFDFD
|
||||
|| value == (unsigned long)0xFFFFFFFF);
|
||||
#else
|
||||
# error "unknown long size"
|
||||
#endif
|
||||
}
|
||||
|
||||
extern int _PyMem_GetAllocatorName(
|
||||
const char *name,
|
||||
PyMemAllocatorName *allocator);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue