This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Thomas
Recipients Thomas, eric.smith, malin
Date 2020-11-16.18:40:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605552007.67.0.00602354620285.issue42369@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-11-16 18:40:07Thomassetrecipients: + Thomas, eric.smith, malin
2020-11-16 18:40:07Thomassetmessageid: <1605552007.67.0.00602354620285.issue42369@roundup.psfhosted.org>
2020-11-16 18:40:07Thomaslinkissue42369 messages
2020-11-16 18:40:06Thomascreate