gh-157429: Make test_detach_materialized_dict_no_memory deterministic - #157444
Open
serhiy-storchaka wants to merge 1 commit into
Open
gh-157429: Make test_detach_materialized_dict_no_memory deterministic#157444serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
…nistic Add _testcapi.call_with_nomemory() which arms the allocation failure, calls a function and removes the memory hooks without executing any bytecode in between, so that pending work at the eval breaker (GC, deferred frees on free-threading builds) cannot consume the failing allocation. The test now drops the last reference from C with this helper, accepts only the unraisable exception reported while clearing the managed dict, and no longer needs to run in a subprocess. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
_testcapi.call_with_nomemory(start, stop, func, /, *args)which arms the allocation failure asset_nomemory(), callsfunc(*args)and removes the memory hooks, without executing any bytecode in between. So the work pending at the eval breaker (GC, deferred frees and refcount merges on free-threading builds) cannot run inside the failure window and consume the failing allocation.The test now drops the last reference from C with
lst.clearpassed to this helper, so the first allocation in the window is always the one indetach_dict_from_object(). It only accepts the unraisable exception reported while clearing the managed dict, and its failure message lists what was actually seen for eachn. Since nothing but the deallocation can run while the hooks are armed, the test no longer needs a subprocess.Keeping
ex.unraisablealive across iterations leaked references once the test ran in-process (gh-157443), so onlyexc_typeanderr_msgare taken out of thewithblock.