From b3b9ade4a3d3fe00d933bcd8fc5c5c755d1024f9 Mon Sep 17 00:00:00 2001 From: Stefan Krah Date: Mon, 2 Mar 2020 21:22:36 +0100 Subject: bpo-39776: Lock ++interp->tstate_next_unique_id. (GH-18746) (#18746) - Threads created by PyGILState_Ensure() could have a duplicate tstate->id. --- Python/pystate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Python') diff --git a/Python/pystate.c b/Python/pystate.c index ebc17ea5a7..4001c63ff2 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -606,13 +606,12 @@ new_threadstate(PyInterpreterState *interp, int init) tstate->context = NULL; tstate->context_ver = 1; - tstate->id = ++interp->tstate_next_unique_id; - if (init) { _PyThreadState_Init(tstate); } HEAD_LOCK(runtime); + tstate->id = ++interp->tstate_next_unique_id; tstate->prev = NULL; tstate->next = interp->tstate_head; if (tstate->next) -- cgit v1.2.1