GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-116738: Make zlib module thread-safe by yoney · Pull Request #142432 · python/cpython

Conversation

@yoney

@yoney yoney commented Dec 8, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Makes the zlib module thread-safe free-threading build. Even though operations are protected by locks, attributes exposed via PyMemberDef (eof, needs_input, unused_data, unconsumed_tail) should still be stored atomically within locked sections, since they can be read without acquiring the lock.

  • Replaced PyThread_type_lock with PyMutex (similar to gh-116738: Use PyMutex for bz2 module #140555 and gh-116738: Use PyMutex for lzma module #140711)
  • Removed ENTER_ZLIB/LEAVE_ZLIB macros in favor of direct PyMutex_Lock/Unlock (similar to gh-116738: Use PyMutex for bz2 module #140555 and gh-116738: Use PyMutex for lzma module #140711)
  • Used FT_ATOMIC_STORE_CHAR_RELAXED for eof and needs_input flag updates inside locked sections (attributes exposed via PyMemberDef)
  • Moved unused_data/unconsumed_tail from PyMemberDef to PyGetSetDef

cc: @mpage @colesbury

  • Issue: Audit all built-in modules for thread safety #116738

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@yoney
pythongh-116738: Make zlib module thread-safe
b219dcc
@bedevere-app bedevere-app Bot mentioned this pull request Dec 8, 2025
Audit all built-in modules for thread safety #116738
Open
@yoney
yoney marked this pull request as ready for review December 8, 2025 22:57
@bedevere-app bedevere-app Bot added the awaiting review label Dec 8, 2025
@colesbury
colesbury requested review from colesbury and mpage December 9, 2025 18:01
colesbury
colesbury reviewed Dec 9, 2025
View reviewed changes
Comment thread Modules/zlibmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

yoney added 2 commits December 11, 2025 09:43
@yoney
Move unused_data and unconsumed_tail to PyGetSetDef
08759e1
@yoney
Restore the Py_SETREFs
57d529f
emmatyping
emmatyping reviewed Dec 11, 2025
View reviewed changes
Comment thread Modules/zlibmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/zlibmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

emmatyping
emmatyping approved these changes Dec 12, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Dec 12, 2025
colesbury
colesbury approved these changes Dec 12, 2025
View reviewed changes
@colesbury
colesbury merged commit 1eddef8 into python:main Dec 12, 2025
50 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Dec 12, 2025
@yoney
yoney deleted the ft_zlib branch January 27, 2026 17:07
@ptweezy ptweezy mentioned this pull request Oct 16, 2026
Fix a crash when reading decompressor attributes from another thread pycompression/python-isal#272
Merged
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@colesbury colesbury colesbury approved these changes
@emmatyping emmatyping emmatyping approved these changes
@mpage mpage Awaiting requested review from mpage

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@yoney @colesbury @emmatyping
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.