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-17.07:17:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605597475.38.0.897451256835.issue42369@roundup.psfhosted.org>
In-reply-to
Content
I have simplified the test case a bit more:

import multiprocessing.pool, zipfile

# Create a ZipFile with two files and same content
with zipfile.ZipFile("test.zip", "w", zipfile.ZIP_STORED) as z:
    z.writestr("file1", b"0"*10000)
    z.writestr("file2", b"0"*10000)

# Read file1  with two threads at once
with zipfile.ZipFile("test.zip", "r") as z:
    pool = multiprocessing.pool.ThreadPool(2)
    while True:
        pool.map(z.read, ["file1", "file1"])

Two files are sufficient to cause the error. It does not matter which files are read or which content they have.

I also narrowed down the point of failure a bit. After

self._file.seek(self._pos)

in _SharedFile.read ( https://github.com/python/cpython/blob/c79667ff7921444911e8a5dfa5fba89294915590/Lib/zipfile.py#L742 ), the following assertion should hold:

assert(self._file.tell() == self._pos)

The issue occurs when seeking to position 35 (size of header + length of name). Most of the time, self._file.tell() will then be 35 as expected, but sometimes it is 8227 instead, i.e. 35 + 8192.

I am not sure how this can happen since the file object should be locked.
History
Date User Action Args
2020-11-17 07:17:55Thomassetrecipients: + Thomas, eric.smith, malin
2020-11-17 07:17:55Thomassetmessageid: <1605597475.38.0.897451256835.issue42369@roundup.psfhosted.org>
2020-11-17 07:17:55Thomaslinkissue42369 messages
2020-11-17 07:17:54Thomascreate