Skip to content

gh-156124: Fix a crash when deleting ctypes Pointer.contents - #156125

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-156124-ctypes-pointer-contents-delete
Open

gh-156124: Fix a crash when deleting ctypes Pointer.contents#156125
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-156124-ctypes-pointer-contents-delete

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 20, 2026

Copy link
Copy Markdown
Member

Pointer_set_contents() entered a critical section on the new value before checking it for NULL, so del ptr.contents crashed the free-threaded build. The check is moved ahead of the critical section.

In the free-threaded build the setter passed the value to
Py_BEGIN_CRITICAL_SECTION2() before checking it for NULL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant