Repository navigation
Fix RUSTSEC-2026-0382 and related dependency advisories - #124
Merged
Merged
Conversation
On Unix every add_reader()/add_writer() readiness wait owns a duplicate of the descriptor. Those waits ran on the coordination thread, so remove_reader() only queued their cancellation, and the duplicate (and with it the kernel socket) could outlive the caller's close(). A closed connected datagram transport could therefore still hold its 4-tuple after connection_lost ran. macOS rejects reconnecting that 4-tuple with EADDRINUSE, which made test_connected_datagram_close_releases_socket_before_callback flaky. Waits armed while the loop runs on its own thread are now tasks on the loop's runtime, and remove_reader()/remove_writer() drop them before returning. Registrations made while the loop is stopped still wait on the coordination thread; a re-arm or replacement while running moves them to the loop thread, and the old wait is cancelled where it runs. The tests check through /proc/self/fd that no duplicate outlives remove_reader() or connection_lost, including registrations that move between the two threads.
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.
Update
Cargo.lockto use compatible patched releases:cargo auditwith a freshly fetched RustSec database (revisionee1a49a2769a24a596afc1c20cb33748d2769586):The remaining warning is RUSTSEC-2025-0134 for rustls-pemfile 2.2.0 being unmaintained. It has no patched release; replacing it requires source changes beyond this lockfile update. No advisories are ignored.
Verified on Linux x86_64 with CPython 3.14.7 and Rust nightly-2026-09-25:
python scripts/run_rust_tests.py: 387 passed.python scripts/run_rust_tests.py --all-features: 478 passed.cargo clippy --all-targets --all-features --locked -- -D warnings: passed.maturin build --locked: built and installed a CPython 3.14 wheel. The native extension's build paths identify all three patched crate versions.python scripts/run_python_tests.py: 616 passed, 124 skipped, 126 deselected.git diff --check: passed.The other platform and Python-version CI matrix entries were not run locally.
Flaky macOS datagram test (fa1c4de)
The first CI run failed only
macos / Python 3.14, intest_connected_datagram_close_releases_socket_before_callback: reconnecting the same UDP 4-tuple raisedEADDRINUSE. The lockfile update did not cause it. Everyadd_reader()/add_writer()wait owns a duplicate of the descriptor and ran on the coordination thread, soremove_reader()only queued its cancellation and the kernel socket could outliveclose(). Linux accepts the duplicate 4-tuple; macOS rejects it.fa1c4de runs waits armed while the loop is running as tasks on the loop's own runtime, and
remove_reader()/remove_writer()drop them before returning. Registrations made while the loop is stopped still wait on the coordination thread and move to the loop thread on re-arm or replacement. New tests check through/proc/self/fdthat no duplicate survivesremove_reader()orconnection_lost, including registrations that move between the threads.Verified on Linux x86_64 with CPython 3.14:
connection_lostand 91 had one during the callback; after it, 0 and 0.python scripts/run_python_tests.py: 727 passed, 12 skipped, 216 deselected (with the ecosystem packages installed).python scripts/run_python_tests.py tests/ecosystem -m ecosystem: 78 passed, 39 skipped. AnyIO integration check: ok.python scripts/run_rust_tests.py: 387 passed;--all-features: 478 passed.cargo clippy --all-targets --all-features --locked -- -D warnings: passed;cargo clippy --lib --all-features --target x86_64-pc-windows-msvc -- -D warnings(type check only): passed.add_reader()ping-pong went from 86k to 246k events/s, and asock_recvfrom()UDP ping-pong from 67.6k to 69.7k round trips/s (within noise).macOS was not run locally; the CI matrix covers it.