[issue9295] test_close_open_print_buffered(test_file) sometimes crashes
Hirokazu Yamamoto
report at bugs.python.org
Mon Jul 19 03:50:44 CEST 2010
Hirokazu Yamamoto <ocean-city at m2.ccsnet.ne.jp> added the comment:
> Does the following patch solve your issue?
I tried, but it still crashed. I could reproduce the crash by following
script. It crashed also on Python2.7, but it doesn't crash on Python3.
And when I used io.open() instead of builtin open(), it doesn't crash
even on Python2.x. (Probably because io.open implements buffer protocol
by itself)
//////////////////////////////////////////////////////
import threading
import sys
if sys.version_info.major == 3:
xrange = range
def main():
size = 1024 * 1024 # large enough
f = open("__temp__.tmp", "w", size)
for _ in xrange(size):
f.write("c")
t1 = threading.Thread(target=f.close)
t2 = threading.Thread(target=f.close)
t1.start()
t2.start()
t1.join()
t2.join()
if __name__ == '__main__':
main()
//////////////////////////////////////////////////////
I lied a bit on msg110655. close(2) is not used, that is actually
fclose(). I didn't notice the variable *close* was declared as
the parameter of fill_file_fields().
----------
versions: +Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9295>
_______________________________________
More information about the Python-bugs-list
mailing list