Title: test_detach_materialized_dict_no_memory depends on the exact number of allocations · Issue #155146 · python/cpython · GitHub
Open Graph Title: test_detach_materialized_dict_no_memory depends on the exact number of allocations · Issue #155146 · python/cpython
X Title: test_detach_materialized_dict_no_memory depends on the exact number of allocations · Issue #155146 · python/cpython
Description: Bug report test_class.TestInlineValues.test_detach_materialized_dict_no_memory (added in gh-124547) uses _testcapi.set_nomemory(0, 1) to fail the first allocation after that call, and assumes that this is the allocation which detaches th...
Open Graph Description: Bug report test_class.TestInlineValues.test_detach_materialized_dict_no_memory (added in gh-124547) uses _testcapi.set_nomemory(0, 1) to fail the first allocation after that call, and assumes that ...
X Description: Bug report test_class.TestInlineValues.test_detach_materialized_dict_no_memory (added in gh-124547) uses _testcapi.set_nomemory(0, 1) to fail the first allocation after that call, and assumes that ...
Opengraph URL: https://github.com/python/cpython/issues/155146
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_detach_materialized_dict_no_memory depends on the exact number of allocations","articleBody":"# Bug report\n\n`test_class.TestInlineValues.test_detach_materialized_dict_no_memory` (added in gh-124547) uses `_testcapi.set_nomemory(0, 1)` to fail the first allocation after that call, and assumes that this is the allocation which detaches the instance dictionary from the object. But `set_nomemory()` hooks all three allocator domains, so any other allocation which happens first consumes the single failure.\n\nThe target is one allocation wide. Failing the *n*-th allocation instead on Linux: n=0 works as intended, n=1..4 kill the process with `MemoryError`, and for n>=5 no `MemoryError` occurs during deallocation at all.\n\nThe test subprocess imports only `test.support` and `_testcapi`, so any change of what `test.support` allocates at import time can shift the sequence.\n\n#155120 is such a change: it adds three functions and a constant to `Lib/test/support/__init__.py`, none of which is used by this test. With it the test fails on the `Windows / Build and test (x64, tail-call)` job:\n\n```\n assert False, \"KeyError not raised\"\nAssertionError: KeyError not raised\n```\n\n`MemoryError` was reported as unraisable during deallocation, but the dictionary was not cleared, because the failing allocation was not the one in the detach code. This is deterministic — 3 failures out of 3, including a re-run of the same commit — while the same job passes on the last 6 commits on main and on the other recent pull requests I checked. It does not reproduce on Linux, nor on the other Windows configurations.\n\nThe tested invariant is correct, only the way it is tested is fragile. I propose to try to fail each of the first allocations and to accept the first one which fails in the detach code.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-155150\n* gh-155155\n* gh-155156\n* gh-155157\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2026-08-04T06:29:43Z","url":"https://github.com/python/cpython/issues/155146"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:faabca84-ee32-55fe-5f73-bd5a2557a426 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DAAC:785A9:3B74F84:4B7626F:6B02020D |
| html-safe-nonce | 81d44968d1d96f36e846d4f3f43849b2414c5c9e839748494cbbc13b7e5e8362 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUFDOjc4NUE5OjNCNzRGODQ6NEI3NjI2Rjo2QjAyMDIwRCIsInZpc2l0b3JfaWQiOiI2MDAzNjA3NjA3MTQ5OTg2MzE4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e7223137a36ba9acf9a0eb159a8a4542908f9346854ec06ed9269fde7fde696b |
| hovercard-subject-tag | issue:5057453385 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/155146/issue_layout |
| twitter:image | https://opengraph.githubassets.com/274186109f3a6a9e3bda586d43a24218007cdbb366eadb50c46768bbe37f310d/python/cpython/issues/155146 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/274186109f3a6a9e3bda586d43a24218007cdbb366eadb50c46768bbe37f310d/python/cpython/issues/155146 |
| og:image:alt | Bug report test_class.TestInlineValues.test_detach_materialized_dict_no_memory (added in gh-124547) uses _testcapi.set_nomemory(0, 1) to fail the first allocation after that call, and assumes that ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width