Repository navigation
Fix Windows runtime validation and 32-bit string size overflows - #9412
Conversation
Validate overlapped receive buffer sizes before starting I/O and preserve spawnv non-TypeError argument failures. Check replacement, tab expansion, and string join sizes before allocation to avoid 32-bit capacity overflows. Implementation, regression investigation, and validation assisted by Codex. Assisted-by: Codex:GPT-5
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. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Checked length calculations crates/vm/src/anystr.rs |
New helpers calculate replacement and tab-expansion lengths with checked arithmetic. Tests cover overflow, size limits, and tab-column behavior. |
Tab expansion crates/common/src/str.rs, crates/vm/src/anystr.rs, crates/vm/src/builtins/{bytearray.rs,bytes.rs,str.rs}, crates/vm/src/bytes_inner.rs |
The common string function appends expansion to a supplied buffer. String and bytes expansion check output capacity and propagate overflow or allocation errors through their builtin methods. |
Replacement and join sizing crates/vm/src/builtins/str.rs, crates/vm/src/bytes_inner.rs |
String join and replacement check output sizes and allocation. Bytes replacement uses checked length calculations and propagates errors for empty-pattern replacement. |
Overlapped receive validation
| Layer / File(s) | Summary |
|---|---|
Receive buffer size check crates/stdlib/src/overlapped.rs |
WSARecvFromInto rejects a requested size larger than the supplied buffer before changing operation state or starting I/O. A unit test checks the error and unchanged state. |
MSVC spawnv argument errors
| Layer / File(s) | Summary |
|---|---|
Argument conversion and error mapping crates/vm/src/stdlib/nt.rs |
On MSVC, argv path-conversion TypeErrors use the specified argument-2 message. Other errors remain unchanged. Tests cover non-string and embedded-null arguments. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Possibly related PRs
- RustPython/RustPython#9406: The PR description says this change follows up on its Windows runtime fixes. Both changes touch Windows runtime behavior, although they modify separate code paths.
Suggested reviewers: 1ndahous3, luantaraschi, joshuamegnauth54
Merge Risk: 
Minimal · up to bd68b
-
The changes add checked sizing and Windows input validation. The spawnv exception behavior matches CPython, and no merge-blocking defect remains identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 8 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/asyncio dependencies:
dependent tests: (9 tests)
[x] lib: cpython/Lib/os.py dependencies:
dependent tests: (191 tests)
Legend:
|
Summary
Follow up the Windows runtime fixes in #9406, without C API, ctypes, PyO3, dependency, or CI changes.
WSARecvFromIntorequests larger than their writable buffer before starting I/O.spawnvargument TypeError while preserving embedded-NUL ValueError and other conversion exceptions.Rebased onto upstream/main at 058bebf.
Validation
cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capipassed after rebase.-D warningspassed. Only the existing linker-messages warning remains (not governed by-D warnings). Separatecrates/capiClippy also passed.i686-pc-windows-msvcinterpreter:test_str test_bytes test_struct test_array test_os test_winapi test_subprocesspassed (9 expanded test files; reported run=2,357, skipped=589).C API tests were attempted separately but remain blocked by missing-symbol link errors outside this PR; no C API fixes are included. The separately reproduced Windows subnormal
math.remainderissue originates in the external pymath dependency and is also excluded. This PR does not claim that every Windows incompatibility is resolved.AI assistance
Codex assisted with implementation, investigation, testing, review, and this PR description. Runtime checks were executed on Windows x64 and x86; no human review is claimed.
Summary by CodeRabbit
spawnvreceive a clearer error; embedded-null errors remain unchanged.