GeezerVison is showing github.com — gh-116738: Make lzma module thread-safe by yoney · Pull Request #142947 · python/cpython
Conversation
yoney
commented
Dec 18, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Make the attributes in lzma module thread-safe on the free-threading build. Attributes (check, eof, needs_input, unused_data) are now stored atomically or accessed via mutex-protected getters.
Even though the operations are protected by locks, the attributes exposed via PyMemberDef (check, eof, needs_input, unused_data) should still be updated atomically while holding the lock, or accessed via mutex‑protected getters, because they can be read without acquiring the lock.
This issue was not addressed in #140711. A small addition that repeatedly reads these attributes shows the issue under tsan build.
WARNING: ThreadSanitizer: data race (pid=2367860)
Atomic read of size 1 at 0x7fdbc9506ee0 by thread T19:
#0 _Py_atomic_load_char_relaxed /workspace/ft_lzma_tsan/./Include/cpython/pyatomic_gcc.h:311 (python+0x99e392) (BuildId: ce943d12d16f92ec125f1db1856a1617d3d75854)
#1 PyMember_GetOne /workspace/ft_lzma_tsan/Python/structmember.c:37 (python+0x99e392)
#2 member_get /workspace/ft_lzma_tsan/Objects/descrobject.c:180 (python+0x60f4d5) (BuildId: ce943d12d16f92ec125f1db1856a1617d3d75854)
...
...
...
Previous write of size 1 at 0x7fdbc9506ee0 by thread T11:
#0 decompress /workspace/ft_lzma_tsan/./Modules/_lzmamodule.c:1067 (_lzma.cpython-315td-x86_64-linux-gnu.so+0x7256) (BuildId: 978a710f12e938f2fbc3233c01c40cf693105ef1)
#1 _lzma_LZMADecompressor_decompress_impl /workspace/ft_lzma_tsan/./Modules/_lzmamodule.c:1139 (_lzma.cpython-315td-x86_64-linux-gnu.so+0x7256)
#2 _lzma_LZMADecompressor_decompress /workspace/ft_lzma_tsan/./Modules/clinic/_lzmamodule.c.h:157 (_lzma.cpython-315td-x86_64-linux-gnu.so+0x7256)
...
...
...
SUMMARY: ThreadSanitizer: data race /workspace/ft_lzma_tsan/./Modules/_lzmamodule.c:1043 in decompress
cc: @mpage @colesbury
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
emmatyping reacted with rocket emoji
Make the attributes in lzma module thread-safe on the free-threading build.
Attributes (check, eof, needs_input, unused_data) are now stored atomically
or accessed via mutex-protected getters.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Looks like jobs failed due to a spurious GitHub outage. I've re-run the failed jobs.
|
yoney reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
picnixz
picnixz approved these changes
emmatyping
Awaiting requested review from emmatyping
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|