Fix ssl-vendor (OpenSSL)#7985
Conversation
📝 WalkthroughWalkthroughThis PR refactors OpenSSL socket waiting to be VirtualMachine-aware and synchronizes a build dependency. The ChangesSSL VM-aware socket waiting
🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes: RustPython#7893 Fix 1: `foreign-types-shared` needs to match `openssl`'s version. Bumping it is a SemVer violation because the latest versions of the crate aren't backwards compatible with older versions. See: rust-openssl/rust-openssl#2461 Fix 2: The second fix is to align the `openssl` module with the latest `host_env` and `ssl` changes.
f9de717 to
d0b84cd
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/stdlib/src/openssl.rs`:
- Around line 2319-2322: The match currently swallows errors from sock_wait;
change the code to propagate sock_wait errors instead of treating them as
SelectRet::Ok—call sock_wait(&*sock, wait_kind, timeout, vm)? (or otherwise map
Err to return the PyErr) and then match on the resulting bool to return
SelectRet::TimedOut or SelectRet::Ok so that errors (signals, EBADF, I/O) are
not discarded; update the block around sock_wait to use the ? operator or
explicit Err->return Err(...) propagation so exceptions bubble up instead of
being converted to SelectRet::Ok.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: c62f895b-4f7a-4004-93a8-8bfbec72063a
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
Cargo.tomlcrates/stdlib/src/openssl.rs
| match sock_wait(&*sock, wait_kind, timeout, vm) { | ||
| Ok(true) => SelectRet::TimedOut, | ||
| _ => SelectRet::Ok, | ||
| } |
There was a problem hiding this comment.
Errors from sock_wait are silently discarded.
sock_wait returns PyResult<bool> and can error with EBADF, signal interrupts, or I/O failures. The wildcard _ catches both Ok(false) (correct) and Err(...) (incorrect), converting errors to SelectRet::Ok. This causes SSL operations to proceed on error and breaks signal responsiveness (e.g., Ctrl+C during handshake).
Consider propagating errors properly:
Proposed fix
- match sock_wait(&*sock, wait_kind, timeout, vm) {
- Ok(true) => SelectRet::TimedOut,
- _ => SelectRet::Ok,
- }
+ match sock_wait(&*sock, wait_kind, timeout, vm) {
+ Ok(true) => SelectRet::TimedOut,
+ Ok(false) => SelectRet::Ok,
+ Err(_) => SelectRet::Closed, // Treat errors as socket unavailable
+ }Note: This is a minimal fix. A more thorough solution would change select to return Result<SelectRet, PyBaseExceptionRef> and propagate the actual exception to callers.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| match sock_wait(&*sock, wait_kind, timeout, vm) { | |
| Ok(true) => SelectRet::TimedOut, | |
| _ => SelectRet::Ok, | |
| } | |
| match sock_wait(&*sock, wait_kind, timeout, vm) { | |
| Ok(true) => SelectRet::TimedOut, | |
| Ok(false) => SelectRet::Ok, | |
| Err(_) => SelectRet::Closed, | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/stdlib/src/openssl.rs` around lines 2319 - 2322, The match currently
swallows errors from sock_wait; change the code to propagate sock_wait errors
instead of treating them as SelectRet::Ok—call sock_wait(&*sock, wait_kind,
timeout, vm)? (or otherwise map Err to return the PyErr) and then match on the
resulting bool to return SelectRet::TimedOut or SelectRet::Ok so that errors
(signals, EBADF, I/O) are not discarded; update the block around sock_wait to
use the ? operator or explicit Err->return Err(...) propagation so exceptions
bubble up instead of being converted to SelectRet::Ok.
ShaharNaveh
left a comment
There was a problem hiding this comment.
TYSM for doing this!
can you please add a somewhere in the CI something that checks it?
I think adding a cargo check --features ... under
RustPython/.github/workflows/ci.yaml
Lines 139 to 141 in dcb273b
Closes: #7893
Fix 1:
foreign-types-sharedneeds to matchopenssl's version. Bumping it is a SemVer violation because the latest versions of the crate aren't backwards compatible with older versions.See: rust-openssl/rust-openssl#2461
Fix 2:
The second fix is to align the
opensslmodule with the latesthost_envandsslchanges.Summary by CodeRabbit
Chores
Refactor