Skip to content

Commit af5d497

Browse files
authored
bpo-44032: Delay deletion of stack chunks until thread state is deleted. (GH-26285)
1 parent 3ad101b commit af5d497

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Python/pystate.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -897,13 +897,6 @@ PyThreadState_Clear(PyThreadState *tstate)
897897
if (tstate->on_delete != NULL) {
898898
tstate->on_delete(tstate->on_delete_data);
899899
}
900-
_PyStackChunk *chunk = tstate->datastack_chunk;
901-
tstate->datastack_chunk = NULL;
902-
while (chunk != NULL) {
903-
_PyStackChunk *prev = chunk->previous;
904-
_PyObject_VirtualFree(chunk, chunk->size);
905-
chunk = prev;
906-
}
907900
}
908901

909902

@@ -936,6 +929,13 @@ tstate_delete_common(PyThreadState *tstate,
936929
{
937930
PyThread_tss_set(&gilstate->autoTSSkey, NULL);
938931
}
932+
_PyStackChunk *chunk = tstate->datastack_chunk;
933+
tstate->datastack_chunk = NULL;
934+
while (chunk != NULL) {
935+
_PyStackChunk *prev = chunk->previous;
936+
_PyObject_VirtualFree(chunk, chunk->size);
937+
chunk = prev;
938+
}
939939
}
940940

941941
static void

0 commit comments

Comments
 (0)