Repository navigation
Align Windows mmap ownership and resize with CPython - #9847
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] test: cpython/Lib/test/test_mmap.py (TODO: 1) dependencies: dependent tests: (2 tests)
Legend:
|
Codex Review Summary: ✅ CompletedThis 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. |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5276794061
ℹ️ 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".
| self.view_ptr = core::ptr::null_mut(); | ||
| if let Err(err) = extend_file(file, max_size as i64) { | ||
| file_resize_error = Some(err); | ||
| max_size = self.len as u64; |
There was a problem hiding this comment.
Include the offset when restoring a failed file resize
On Windows, when a file-backed mapping has a nonzero offset and another view of the same file prevents resizing, extend_file fails and this fallback sets the replacement section’s maximum size to only self.len. The subsequent MapViewOfFile still requests self.len bytes at the original offset, exceeding that section’s bounds and causing PyMmap::resize to mark the mapping closed. For example, a 4096-byte view at ALLOCATIONGRANULARITY becomes unusable after catching the resize error, whereas the previous backend restored it. Use offset + self.len as the fallback section size so reads and subsequent resize retries remain possible.
Useful? React with 👍 / 👎.
Summary
Make Windows mmap creation and resizing follow CPython 3.15's native mapping lifecycle rather than splitting named mappings and ordinary mappings between two implementations.
trackfd=True, including for named mappings; use the duplicate after acquiring it.CreateFileMappingWenforce access and extend files. Apply anonymous offsets too, and preserve the Windows constructor's CRT cursor-reset behavior.Modules/mmapmodule.c. Keep the cursor unchanged when shrinking.__index__inresizeon Linux and Windows, preserving signed-size overflow diagnostics.msyncpath.MmapTestsclass. The first Windows CI run confirmed 15 unexpected successes; remove exactly those obsolete expected-failure markers. The POSIX-only test’s remaining Windows marker is unchanged.The added regression cases live in the existing
stdlib_mmap.pysnippet. They cover gaps in the stdlib tests: index conversion/reentrancy, the cursor after shrink, named file size and successful named resize, anonymous offset handling, and explicit close after a failed resize. No WASI mmap implementation changes.Validation
stdlib_mmap.pysnippet passes on Linux.-m test test_mmappasses (55 tests, 7 skipped).cargo check -p rustpython-host_env --target x86_64-pc-windows-gnupasses.-D warningspasses.stdlib_mmap.pysnippet pass.-m test test_mmappasses (55 tests, 7 skipped).git diff --checkpass.Windows CI also ran the complete
stdlib_mmap.pysnippet successfully under both CPython and RustPython, including the Windows-specific regression cases.Windows runtime evidence from head
efb849e90: Windows CI executedtest_mmap(55 tests, 7 skipped) and failed only because 15 tests unexpectedly passed. Those exact 15 markers are removed in the follow-up commit; no implementation changes were needed. The latest head's CI is pending. No Windows performance measurement has been performed.Summary by CodeRabbit