summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2020-03-03 08:18:55 (GMT)
committerGitHub <noreply@github.com>2020-03-03 08:18:55 (GMT)
commit5a92f42d8723ee865be80f028d402204649da15d (patch)
tree97fa71b2c400f514e26d86748e2e23cf6aed3e0c /Python
parent1827fc30f463786ebff13752e35c3224652bc94e (diff)
downloadcpython-5a92f42d8723ee865be80f028d402204649da15d.zip
cpython-5a92f42d8723ee865be80f028d402204649da15d.tar.gz
cpython-5a92f42d8723ee865be80f028d402204649da15d.tar.bz2
bpo-39776: Lock ++interp->tstate_next_unique_id. (GH-18746) (#18746) (#18752)
- Threads created by PyGILState_Ensure() could have a duplicate tstate->id. (cherry picked from commit b3b9ade4a3d3fe00d933bcd8fc5c5c755d1024f9)
Diffstat (limited to 'Python')
-rw-r--r--Python/pystate.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index aba673c..9f99060 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(runtime, tstate);
}
HEAD_LOCK(runtime);
+ tstate->id = ++interp->tstate_next_unique_id;
tstate->prev = NULL;
tstate->next = interp->tstate_head;
if (tstate->next)