mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
[3.14] gh-134144: Fix use-after-free in zapthreads() (GH-134145) (#134182)
gh-134144: Fix use-after-free in zapthreads() (GH-134145)
(cherry picked from commit f2de1e6861)
Co-authored-by: b-pass <b-pass@users.noreply.github.com>
This commit is contained in:
parent
8d51ed6b05
commit
bb5f92adcf
4 changed files with 41 additions and 6 deletions
|
|
@ -1908,9 +1908,14 @@ tstate_delete_common(PyThreadState *tstate, int release_gil)
|
|||
static void
|
||||
zapthreads(PyInterpreterState *interp)
|
||||
{
|
||||
PyThreadState *tstate;
|
||||
/* No need to lock the mutex here because this should only happen
|
||||
when the threads are all really dead (XXX famous last words). */
|
||||
_Py_FOR_EACH_TSTATE_UNLOCKED(interp, tstate) {
|
||||
when the threads are all really dead (XXX famous last words).
|
||||
|
||||
Cannot use _Py_FOR_EACH_TSTATE_UNLOCKED because we are freeing
|
||||
the thread states here.
|
||||
*/
|
||||
while ((tstate = interp->threads.head) != NULL) {
|
||||
tstate_verify_not_active(tstate);
|
||||
tstate_delete_common(tstate, 0);
|
||||
free_threadstate((_PyThreadStateImpl *)tstate);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue