We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 00c69d2 commit a91fc22Copy full SHA for a91fc22
Python/tracemalloc.c
@@ -870,7 +870,8 @@ _PyTraceMalloc_Stop(void)
870
TABLES_LOCK();
871
872
if (!tracemalloc_config.tracing) {
873
- goto done;
+ TABLES_UNLOCK();
874
+ return;
875
}
876
877
/* stop tracing Python memory allocations */
@@ -887,10 +888,12 @@ _PyTraceMalloc_Stop(void)
887
888
raw_free(tracemalloc_traceback);
889
tracemalloc_traceback = NULL;
890
- (void)PyRefTracer_SetTracer(NULL, NULL);
891
-
892
-done:
893
TABLES_UNLOCK();
+
+ // Call it after TABLES_UNLOCK() since it calls _PyEval_StopTheWorldAll()
894
+ // which would lead to a deadlock with TABLES_LOCK() which doesn't release
895
+ // the GIL.
896
+ (void)PyRefTracer_SetTracer(NULL, NULL);
897
898
899
0 commit comments