Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
import gc
import sys
import threading
stop = threading.Event()
def writer():
while not stop.is_set():
sys.stderr.write("x\n")
t = threading.Thread(target=writer)
t.start()
gc.set_debug(gc.DEBUG_COLLECTABLE)
for _ in range(1000):
a = []
a.append(a)
del a
gc.collect()
gc.set_debug(0)
stop.set()
t.join()
print("done")From initial investigation, during a stop the world for GC debug collectables is printed which can occur whilst the BufferedWriter lock is being held. Debug for uncollectables is instead called outside this critical section and does not have this deadlock pattern.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
gh-161366: Fix deadlock with FT GC debug collectables print (#161444)