Thomas <thger...@hhu.de> added the comment:

I have not observed any segfaults yet. Only zipfile.BadZipFile exceptions so 
far.

The exact file at which it crashes is fairly random. It even crashes if all 
threads try to read the same file multiple times.

I think the root cause of the problem is that the reads of zef_file in 
ZipFile.read are not locked properly.

https://github.com/python/cpython/blob/c79667ff7921444911e8a5dfa5fba89294915590/Lib/zipfile.py#L1515

The underlying file object is shared between all ZipExtFiles. Every time a 
thread makes a call to ZipFile.read, a new lock is created in _SharedFile, but 
that lock only protects against multiple threads reading the same ZipExtFile. 
Multiple threads reading different ZipExtFiles with the same underlying file 
object will cause trouble. The locks do nothing in this scenario because they 
are individual to each thread and not shared.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to