Crash report
del ptr.contents crashes the free-threaded build.
>>> from ctypes import POINTER, c_int
>>> ptr = POINTER(c_int)(c_int(42))
>>> del ptr.contents
Segmentation fault
Pointer_set_contents() passes the new value to Py_BEGIN_CRITICAL_SECTION2(), which dereferences it to get the mutex, but the value is NULL when the attribute is deleted. The check for NULL is in Pointer_set_contents_lock_held(), which is only called after the critical section is entered.
With the GIL it raises TypeError: Pointer does not support item deletion.
The critical section was added in gh-128182, so this affects 3.14 and newer.
Linked PRs
Crash report
del ptr.contentscrashes the free-threaded build.Pointer_set_contents()passes the new value toPy_BEGIN_CRITICAL_SECTION2(), which dereferences it to get the mutex, but the value isNULLwhen the attribute is deleted. The check forNULLis inPointer_set_contents_lock_held(), which is only called after the critical section is entered.With the GIL it raises
TypeError: Pointer does not support item deletion.The critical section was added in gh-128182, so this affects 3.14 and newer.
Linked PRs