GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||
GeezerVison is showing github.com — Prevent ContextVar cache hits after Context address reuse by youknowdot · Pull Request #9009 · RustPython/RustPython Conversation
Contributor
SummaryExtract the ContextVar cache-identity fix from #8954 for the Python 3.14 main branch. A ContextVar can retain a cached value after its Context is destroyed. If a new empty Context reuses that address at the same stack depth, the old address-based cache check can return the destroyed Context's value even though the new mapping is empty. Give every Context, including copies, a non-reused cache identity. If the identity counter saturates, zero disables cache hits. Existing cache locking and replacement/drop ordering stay intact. Add a Rust interpreter regression for fresh and copied contexts, variable defaults, explicit defaults, and missing-value errors. This changes one implementation file and adds one integration test. Canonical Python tests, dependencies and build profiles are unchanged. ValidationIndependently validated on main-based head
Local execution was Linux only. Asyncio cohorts requiring the sandbox-denied AF_UNIX socketpair were not run; hosted tests remain enabled and cross-platform CI is pending. Counter exhaustion was source-reviewed without mutating the global counter. The available CPython comparison was 3.15.0rc3, not a CPython 3.14 reference run. AI assistanceCodex assisted with implementation, extraction, source review, regression tests, and automated validation. The original implementation authorship and
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsGive each Context, including copies, a non-reused cache identity instead of using its heap address. Disable cache hits if the identity counter saturates. This prevents an empty Context from reading a destroyed Context's cached value while preserving existing locking and drop order. Assisted-by: Codex:model-version-unavailable Exercise fresh and copied contexts with variable defaults, explicit defaults and missing values. The repeated lifecycle check complements canonical context tests without relying on a fixed allocator address-reuse count. Assisted-by: Codex:model-version-unavailable
|
There was an error while loading. Please reload this page.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (2)
✨ 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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
do not add python test code here. put it under extra_tests/snippets
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Preserve the fresh and copied Context lifetime checks, defaults and missing-value assertions while removing the redundant Rust interpreter wrapper. Assisted-by: Codex:model-version-unavailable
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: 85361fa4e6
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ] == [] | ||
|
|
||
|
|
||
| def context_cache_does_not_outlive_its_context(): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Remove the prohibited test-body addition
This block adds a new test function, assertions, and test data to extra_tests/snippets/stdlib_contextvars.py, but the repository's critical test-code policy limits test-file edits to adding or removing expected-failure decorators and their associated TODOs. Remove this new test-body logic before landing the change.
AGENTS.md reference: AGENTS.md:L273-L279
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.