Skip to content

Commit f4e6928

Browse files
committed
Patch 1413181, by Gabriel Becedillas.
PyThreadState_Delete(): if the auto-GIL-state machinery knows about the thread state, forget it (since the thread state is being deleted, continuing to remember it can't help, but can hurt if another thread happens to get created with the same thread id). I'll backport to 2.4 next.
1 parent 8622e93 commit f4e6928

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ Core and builtins
230230
unicode instance if the argument is not an instance of basestring and
231231
calling __str__ on the argument returns a unicode instance.
232232

233+
- Patch #1413181: changed ``PyThreadState_Delete()`` to forget about the
234+
current thread state when the auto-GIL-state machinery knows about
235+
it (since the thread state is being deleted, continuing to remember it
236+
can't help, but can hurt if another thread happens to get created with
237+
the same thread id).
238+
233239
Extension Modules
234240
-----------------
235241

Python/pystate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ PyThreadState_Delete(PyThreadState *tstate)
262262
if (tstate == _PyThreadState_Current)
263263
Py_FatalError("PyThreadState_Delete: tstate is still current");
264264
tstate_delete_common(tstate);
265+
#ifdef WITH_THREAD
266+
if (autoTLSkey && PyThread_get_key_value(autoTLSkey) == tstate)
267+
PyThread_delete_key_value(autoTLSkey);
268+
#endif /* WITH_THREAD */
265269
}
266270

267271

0 commit comments

Comments
 (0)