Skip to content

gh-155363: Fix QSBR slot leak on thread state creation failure - #155365

Open
nascheme wants to merge 1 commit into
python:mainfrom
nascheme:gh-155363-fix-qsbr-reserve-leak
Open

gh-155363: Fix QSBR slot leak on thread state creation failure#155365
nascheme wants to merge 1 commit into
python:mainfrom
nascheme:gh-155363-fix-qsbr-reserve-leak

Conversation

@nascheme

@nascheme nascheme commented Aug 7, 2026

Copy link
Copy Markdown
Member

In the free-threaded build, new_threadstate() reserves a QSBR thread-state slot before it can still fail for other reasons, but the failure paths only called free_threadstate(), which does not know about the reservation.

Add _Py_qsbr_unreserve() which returns the unregistered entry to the freelist.

In the free-threaded build, new_threadstate() reserves a QSBR thread-state
slot before it can still fail for other reasons, but the failure paths only
called free_threadstate(), which does not know about the reservation.
@nascheme nascheme added performance Performance or resource usage topic-free-threading needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 7, 2026
@nascheme
nascheme marked this pull request as ready for review August 7, 2026 21:29
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.15 pre-release feature fixes, bugs and security fixes performance Performance or resource usage topic-free-threading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant