Skip to content

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

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-156124-ctypes-pointer-contents-delete
Aug 21, 2026
Merged

serhiy-storchaka merged 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.
@serhiy-storchaka serhiy-storchaka added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Aug 20, 2026
@serhiy-storchaka
serhiy-storchaka merged commit ca6e733 into python:main Aug 21, 2026
60 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@serhiy-storchaka
serhiy-storchaka deleted the gh-156124-ctypes-pointer-contents-delete branch August 21, 2026 07:05
@bedevere-app

bedevere-app Bot commented Aug 21, 2026

Copy link
Copy Markdown

GH-156153 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Aug 21, 2026
@bedevere-app

bedevere-app Bot commented Aug 21, 2026

Copy link
Copy Markdown

GH-156154 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 21, 2026
serhiy-storchaka added a commit that referenced this pull request Aug 21, 2026
…H-156125) (GH-156154)

In the free-threaded build the setter passed the value to
Py_BEGIN_CRITICAL_SECTION2() before checking it for NULL.
(cherry picked from commit ca6e733)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request Oct 10, 2026
…H-156125) (GH-156153)

In the free-threaded build the setter passed the value to
Py_BEGIN_CRITICAL_SECTION2() before checking it for NULL.
(cherry picked from commit ca6e733)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant