Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-132296: Use thread-state reference counting to fix PyEval_SetTraceAllThreads #132298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use the reference count in PyThreadState_Delete()
  • Loading branch information
ZeroIntensity committed Apr 9, 2025
commit 3169e82db0b1ab2661b58673d914b7b6f2aa0dfb
12 changes: 9 additions & 3 deletions 12 Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1896,9 +1896,15 @@ void
PyThreadState_Delete(PyThreadState *tstate)
{
_Py_EnsureTstateNotNULL(tstate);
tstate_verify_not_active(tstate);
tstate_delete_common(tstate, 0);
decref_threadstate((_PyThreadStateImpl *)tstate);
_PyThreadStateImpl *impl = (_PyThreadStateImpl *)tstate;
if (_Py_atomic_add_ssize(&impl->refcount, -1) == 2) {
/* Treat the interpreter's reference (via the linked list) as weak,
even though it's technically strong. This is because we want
to free the thread state now, rather than wait for finalization. */
tstate_verify_not_active(tstate);
tstate_delete_common(tstate, 0);
free_threadstate((_PyThreadStateImpl *)tstate);
}
}


Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.