Skip to content

Commit 32e7415

Browse files
committed
Lock around atexit_cleanup
1 parent 5cc26fe commit 32e7415

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Modules/atexitmodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ void
120120
_PyAtExit_Fini(PyInterpreterState *interp)
121121
{
122122
struct atexit_state *state = &interp->atexit;
123-
// Only one thread can call this, no need to lock it
123+
// Only one thread can call this, but atexit_cleanup_locked() assumes
124+
// that the lock is held, so let's hold it anyway.
124125
_PyAtExit_ASSERT_UNLOCKED(state);
125-
126+
_PyAtExit_LOCK(state);
126127
atexit_cleanup_locked(state);
128+
_PyAtExit_UNLOCK(state);
127129
PyMem_Free(state->callbacks);
128130
state->callbacks = NULL;
129131

0 commit comments

Comments
 (0)