require PyCFunction::new_closure closures to be Sync#6096
Merged
Conversation
Closed
Member
Author
|
Wow, I hadn't noticed that we had violated this bound within our own test suite 😬 |
Tpt
approved these changes
Jun 4, 2026
4 tasks
This was referenced Jun 12, 2026
RUSTSEC-2026-0177: Missing
Sync bound on PyCFunction::new_closure closures
mihai-dinculescu/tapo#580
Open
Open
Open
Open
Closed
Open
This was referenced Jun 12, 2026
mikbry
added a commit
to mikbry/ui
that referenced
this pull request
Jun 12, 2026
) (#115) Two RUSTSEC advisories published 2026-06-11 against pyo3 0.28.x, both fixed in 0.29.0: - RUSTSEC-2026-0176 — out-of-bounds read (memory exposure) in BoundListIterator/BoundTupleIterator nth/nth_back (PyO3/pyo3#6086) - RUSTSEC-2026-0177 — missing Sync bound on PyCFunction::new_closure closures (PyO3/pyo3#6096) mkui-py calls none of the affected APIs, so this is a pure dependency bump with no source changes. Version lives in [workspace.dependencies]; mkui-py consumes it via { workspace = true }. Verified locally: - cargo deny check advisories — ok (both IDs resolved) - cargo audit — no vulnerabilities - cargo test -p mkui-py --no-default-features --features parity-test,console — pass - cargo fmt/clippy/test/doc/release — all green - no new transitive deps, no MSRV change (0.29 needs 1.63; workspace is 1.87) Closes #114 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
It turns out that
PyCFunction::new_closurehas a thread-safety bug - the closure is not required to beSync. This is worse under the free-threaded build, but also a problem under the GIL-enabled build because of the existence ofPython::detach()allowing the closure to do work without synchronization.I think this is worth reporting to the RustSec Advisory Database; it is possible that existing user code is affected and subtly broken.
I couldn't think of a way to test for this other than UI tests.
(Credit to Claude for the discovery.)