Repository navigation
Fix optional OpenSSL duplex I/O on Unix - #9173
Conversation
Release connection locks before readiness waits while serializing native SSL attempts and preserving owned write retries. Wake waiters on native progress and socket identity invalidation, and construct callback/native exceptions after unlocking. Add regression coverage to the existing SSL snippet and run the optional OpenSSL backend in the existing Unix CI matrix. Windows and AIX retain the legacy transport pending a separate compatibility-safe driver. Assisted-by: OpenAI Codex:model version unavailable
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
check once again not to add duplicated test in test_ssl.py
There was a problem hiding this comment.
Rechecked against the canonical cases. The connection/handshake setup overlaps, but these added failure conditions are different:
- MemoryBIOTests.test_buffer_types checks accepted buffer types. The snippet resizes the original exporter after WANT_READ, then retries with the saved original bytes.
- test_nonblocking_send fills the socket until WANT and closes it. The snippet requires application WANT_WRITE, releases/resizes the exporter, then checks valid retry and exact delivery through EOF.
- The canonical duplex test covers a blocking reader with a concurrent sender. test_msg_callback_deadlock_bpo43577 covers an SNI context switch. The added callback case specifically waits for the writer to return while the other thread's read callback is running, exercising write-owner cleanup.
I couldn't find those assertions in test_ssl.py. The snippet reuses its server implementation with bounded cleanup; test_ssl.py itself remains unchanged and is still run in full.
There was a problem hiding this comment.
@youknowone It sounds like these failure conditions are good candidates to add to the upstream CPython test suite.
|
|
||
| # Keep this after the default-backend checks: rebuilding replaces the | ||
| # release interpreter. Windows still needs a nonblocking OpenSSL driver. | ||
| - name: Build optional OpenSSL runtime |
There was a problem hiding this comment.
didn't we arleady have openssl test in CI?
There was a problem hiding this comment.
Yes, the existing OpenSSL and vendored OpenSSL steps check minimal-feature compilation on Linux. They don't run SSL tests. The normal snippet/CPython jobs use CARGO_ARGS with ssl-rustls-aws-lc.
The added steps run the shared snippet and unchanged canonical test_ssl with ssl-openssl on Linux/macOS. This covers the backend affected by this PR. I kept the existing compile-only gates because their minimal feature configurations are distinct; replacing them with the runtime build would remove that coverage. Windows retains its existing default-backend checks while the OpenSSL transport limitation remains documented.
There was a problem hiding this comment.
ok combine this test to the existing one. do not add new task for that
There was a problem hiding this comment.
Combined in 0617d62. The existing “Test openssl build” step now runs the release build, SSL snippet and canonical test_ssl; the three separate steps are removed. The original minimal-feature build command and vendored build check are preserved. The existing step also runs on macOS with its OpenSSL dependency enabled. Fresh CI is running for this commit.
There was a problem hiding this comment.
Follow-up #9177 removes the added macOS OpenSSL build and runtime work. The consolidated checks now stay in the existing Linux OpenSSL step; its minimal-feature, runtime and vendored coverage are preserved. Other macOS jobs are unchanged.
Keep the minimal system and vendored OpenSSL build checks, and run the Unix SSL regressions in the existing system OpenSSL step. Preserve the runtime feature set and enable its macOS dependency in that job. Assisted-by: OpenAI Codex:model version unavailable
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0617d62275
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try: | ||
| client.write(exporter) |
There was a problem hiding this comment.
Remove the prohibited test logic additions
This starts a newly added test scenario, and the remainder of this file adds substantial test data, assertions, helper classes, and test bodies; the repository's critical test rule permits test-file changes only for adding or removing expectedFailure markers, so these additions need to be removed from this change regardless of whether the runtime implementation passes them.
AGENTS.md reference: AGENTS.md:L276-L282
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The maintainer's snippet-specific policy is to avoid Lib/test duplication and add new cases to the closest existing snippet, as recorded in AGENTS.md. These additions follow that direction. The canonical-test comparison identifies the distinct exporter-release, saved-byte retry and callback-cleanup assertions. Existing assertions and Lib/test/test_ssl.py are unchanged. I'm retaining this regression coverage rather than removing it solely because it adds test logic.
Remove the macOS OpenSSL build and runtime expansion from #9173 while preserving the existing Linux checks and other macOS jobs. Assisted-by: OpenAI Codex:model version unavailable
Fix optional OpenSSL duplex I/O on Unix
Follow-up to #9167. A blocking read currently holds the connection lock while waiting for network input, preventing a concurrent write on the same TLS connection from making progress.
This change removes that deadlock on Unix platforms with
MSG_DONTWAIT, without changing the shared socket's blocking flags. Windows and AIX retain the legacy transport and its blocking-I/O limitation. Linux and macOS optional OpenSSL runtime validation passed in hosted CI; the local results below are Linux only.Implementation
WANT_WRITEprevents conflicting native calls;WANT_READpermits safe read progress.WANT_WRITEfollowed by valid saved-byte retry and exact delivery/EOF. Positive partial writes are supported.Lib/test/test_ssl.pyremains untouched, with no new exclusion or weakened assertion.A timed-out, interrupted or nonblocking write can retain a native continuation. Retry with the same bytes and length. Until an abandoned
WANT_WRITEcontinuation is retried, conflicting I/O reportsSSLWantWriteErrorinstead of making a forbidden native call. Close/detach remain escape routes; equal concurrent writes are still distinct calls.This addresses the lock held across a read-readiness wait. Strict OpenSSL
WANT_WRITEownership does not guarantee liveness under arbitrary two-peer backpressure. Acquiring the native lock behind a long-running Python callback is not newly deadline-aware.Validation
Locally on the final tree rebased onto
fc9f4a9(native tests/checks use their normal Cargo profiles; interpreter runtime checks use fresh release binaries):test_ssl: OpenSSL 215 total / 189 executed passes / 26 skips; default rustls 215 total / 175 executed passes / 40 skips.Additional completed evidence before the importlib rebase and mechanical lint cleanup: workspace native 1,369 passes; separate ABI3T C-API 123 passes / 4 ignores; workspace docs 24 passes / 18 ignores; C-API docs had no cases. Workspace and separate C-API Clippy passed. The production retry/wakeup implementation was unchanged by that cleanup.
That earlier source also passed 20 TLS 1.3 and 20 TLS 1.2-bound invocations of the canonical duplex method, plus CPython-first timeout/callback and certificate-metadata checks. These are bounded scheduling/compatibility checks, not exhaustive stress or fuzz coverage. Existing resource/platform skips remain. Broad local
test_socketwas not run; socket evidence consists of native identity tests and canonical SSL lifecycle coverage.Main hosted CI passed all 25 jobs at
0617d622, including actionlint and the mandatory zizmor scan. The optional OpenSSL build, shared snippet and unchanged full SSL suite passed on both Linux (OpenSSL 3.0.13) and macOS (OpenSSL 4.0.3). Each hosted SSL run reported 215 total / 186 executed passes / 29 skips, with the canonical duplex and callback-exception methods executed successfully. Windows default-backend CI passed; optional OpenSSL runtime steps were intentionally not run there. The consolidated Linux/macOS Rust jobs finished in 29m32s and 26m50s, within the unchanged 45-minute job limit.The separate CodSpeed run failed during its build with exit code 143 before any benchmarks executed. No Rust diagnostic was reported; a maintainer rerun is needed. This remains a failed check, separate from the successful main CI.
Windows needs a separately agreed transport compatibility contract. The existing trailing-
NoneSSL exceptionargsmismatch and rustls callback-settlement follow-ups are outside this change.AI assistance
Implementation, test preparation and review were assisted by OpenAI Codex (model version unavailable).
Summary by CodeRabbit
Bug Fixes
Tests