-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Closed as not planned
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixestopic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Crash report
What happened?
This code segfaults for me
import threading
import gc
import torch
def main():
def worker(wid):
for i in range(100):
t = torch.zeros(1000)
cond = threading.Condition()
if i % 10 == 0:
gc.collect()
print(f"W{wid} done")
threads = [threading.Thread(target=worker, args=(i,)) for i in range(40)]
for t in threads: t.start()
for t in threads: t.join()
print(" PASSED")
if __name__ == "__main__":
main()I am unclear why. I haven't been able to reproduce it without pytorch and even stranger is that the threading.Condition() is not used. It leads me to think there's a race in the garbage collection process and the tensor + Condition happen to trigger some specific states but I haven't been able to characterize that yet.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0 free-threading build (main, Nov 19 2025, 22:48:09) [Clang 21.1.4 ]
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixestopic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump