Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[3.9] bpo-42369: Fix thread safety of zipfile._SharedFile.tell (GH-26974) #32008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2022

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Mar 20, 2022

The _SharedFile tracks its own virtual position into the file as
self._pos and updates it after reading or seeking. tell() should
return this position instead of calling into the underlying file object,
since if multiple _SharedFile instances are being used concurrently on
the same file, another one may have moved the real file position.
Additionally, calling into the underlying tell may expose thread
safety issues in the underlying file object because it was called
without taking the lock.
(cherry picked from commit e730ae7)

Co-authored-by: Kevin Mehall [email protected]

https://bugs.python.org/issue42369

)

The `_SharedFile` tracks its own virtual position into the file as
`self._pos` and updates it after reading or seeking. `tell()` should
return this position instead of calling into the underlying file object,
since if multiple `_SharedFile` instances are being used concurrently on
the same file, another one may have moved the real file position.
Additionally, calling into the underlying `tell` may expose thread
safety issues in the underlying file object because it was called
without taking the lock.
(cherry picked from commit e730ae7)

Co-authored-by: Kevin Mehall <[email protected]>
@miss-islington
Copy link
Contributor Author

@kevinmehall and @serhiy-storchaka: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 4aa8b80 into python:3.9 Mar 20, 2022
@miss-islington miss-islington deleted the backport-e730ae7-3.9 branch March 20, 2022 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants