Skip to content

Commit 94a75f7

Browse files
authored
gh-155504: Set the interpreter before fallible thread state initialization (#155590)
1 parent e3287f6 commit 94a75f7

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a crash when thread state creation fails before the thread state is fully
2+
initialized.

Python/pystate.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,8 @@ alloc_threadstate(PyInterpreterState *interp)
15081508
}
15091509
reset_threadstate(tstate);
15101510
}
1511+
// Set the interpreter before any later initialization can fail.
1512+
tstate->base.interp = interp;
15111513
return tstate;
15121514
}
15131515

0 commit comments

Comments
 (0)