[issue3139] bytearrays are not thread safe

Antoine Pitrou report at bugs.python.org
Sat Jul 5 20:39:19 CEST 2008


Antoine Pitrou <pitrou at free.fr> added the comment:

By the way, here's a more reliable way to make it crash (on my Linux
machine):


import bz2, threading

bz2c = bz2.BZ2Compressor()
# Span at least a whole arena (256KB long)
junk_len = 512 * 1024
junk = b"a" * junk_len
buf = bytearray()

for x in range(50):
    buf[:] = junk
    t = threading.Thread(target=bz2c.compress, args=[buf])
    t.start()
    buf[:] = b""
    t.join()

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3139>
_______________________________________


More information about the Python-bugs-list mailing list