Fix subinterpreter lifecycle edge cases - #8632
Conversation
Preserve logical memoryview descriptors across interpreter transfers, make channel-end release idempotent, and scope runtime-owned interpreter cleanup to the creating top-level runtime. Re-read owned interpreters during shutdown so finalizers cannot leave newly-created children behind. Add regression coverage for sliced and cast memoryviews, repeated channel release, and multiple embedded runtimes. Assisted-by: Codex:GPT-5
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe changes preserve memoryview descriptor metadata, make channel-end release idempotent, and scope owned subinterpreter cleanup to each runtime. Tests cover buffer round-tripping, repeated release, and isolation between embedded runtimes. ChangesRuntime and channel correctness
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: 🔵 Low · up to The PR improves subinterpreter isolation and cleanup, preserves memoryview behavior across interpreters, and makes channel-end release safe to repeat. A shutdown-time finalizer may still create a child after cleanup has completed, allowing that child to outlive its runtime; the change is mergeable with explicit owner awareness or follow-up for this bounded lifecycle risk. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
Preserve logical memoryview descriptors across interpreter transfers, make channel-end release idempotent, and scope runtime-owned interpreter cleanup to the creating top-level runtime. Re-read owned interpreters during shutdown so finalizers cannot leave newly-created children behind. Add regression coverage for sliced and cast memoryviews, repeated channel release, and multiple embedded runtimes. Assisted-by: Codex:GPT-5
One of checkbox below must be checked.
Summary
Follow-up to #8605 addressing valid findings from post-merge review:
The behavior was compared against CPython 3.14.7. Two other review suggestions were intentionally not included: CPython has the same
EXTENDED_ARGlimitation in_PyCode_ReturnsOnlyNone(), and its absolute-path construction also produces the observed double separator for a root working directory.Testing
cargo clippyINSTA_WORKSPACE_ROOT=/Users/youknowone/Projects/RustPython-11 cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi(cd crates/capi && cargo test)(103 passed)prek run --from-ref upstream/main --to-ref HEADcargo test -p rustpython-vm releasing_an_end_twice_is_a_noopcargo test -p rustpython-vm --features threading owned_subinterpreter_cleanup_is_scoped_to_its_runtimecargo run -- extra_tests/snippets/stdlib_subinterpreters.pyAI assistance
OpenAI Codex (GPT-5) assisted extensively with CPython source comparison, implementation, regression-test design, independent review coordination, validation, commit preparation, and this pull request description. The contributor reviewed the findings and directed which valid issues to address.
Summary by CodeRabbit