bytearray is not memory safe in free-threaded Python #127472
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
topic-free-threading
type-bug
An unexpected behavior, bug, or error
Bug report
Bug description:
While working on improving the compatibility of PyO3's
bytearray
wrapper with free-threaded Python (3.13t), I ended up looking at thebytearray
implementation and couldn't see any critical sections or other synchronization mechanisms. This led me to believe that usingbytearray
s concurrently (pure python) might not be memory safe. I managed to write a reproducer:Obviously, this is a racy program and I don't expect it to be very useful. But
worker2
should never be seeing the garbage ofworker3
. Yet it does.The output I got:
CPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: