Title: Many places have missing `PyErr_NoMemory()` call after failing memory allocation · Issue #151126 · python/cpython · GitHub
Open Graph Title: Many places have missing `PyErr_NoMemory()` call after failing memory allocation · Issue #151126 · python/cpython
X Title: Many places have missing `PyErr_NoMemory()` call after failing memory allocation · Issue #151126 · python/cpython
Description: Crash report remove_unused_consts in Python/flowgraph.c When PyMem_Malloc(nconsts * sizeof(Py_ssize_t)); fails, we need to set an exception. cpython/Python/flowgraph.c Lines 3267 to 3283 in 29a920e static int remove_unused_consts(basicbl...
Open Graph Description: Crash report remove_unused_consts in Python/flowgraph.c When PyMem_Malloc(nconsts * sizeof(Py_ssize_t)); fails, we need to set an exception. cpython/Python/flowgraph.c Lines 3267 to 3283 in 29a920e...
X Description: Crash report remove_unused_consts in Python/flowgraph.c When PyMem_Malloc(nconsts * sizeof(Py_ssize_t)); fails, we need to set an exception. cpython/Python/flowgraph.c Lines 3267 to 3283 in 29a920e...
Opengraph URL: https://github.com/python/cpython/issues/151126
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Many places have missing `PyErr_NoMemory()` call after failing memory allocation","articleBody":"# Crash report\n\n1. `remove_unused_consts` in `Python/flowgraph.c`\n\nWhen `PyMem_Malloc(nconsts * sizeof(Py_ssize_t));` fails, we need to set an exception.\n\nhttps://github.com/python/cpython/blob/29a920e80e21490b5bdb7178373f80fe606a4403/Python/flowgraph.c#L3267-L3283\n\n2. `gethandlelist` and `getattributelist` in `_winapi.c`\n\nThis place misses it:\n\nhttps://github.com/python/cpython/blob/9fdbade99e6bcc607d9f12416bfca5bbf94022b9/Modules/_winapi.c#L1196-L1198\n\nAll other error paths set exceptions, except this `if`:\n\nhttps://github.com/python/cpython/blob/9fdbade99e6bcc607d9f12416bfca5bbf94022b9/Modules/_winapi.c#L1278-L1282\n\n3. `_channelends_new` in `Modules/_interpchannelsmodule.c`\n\nhttps://github.com/python/cpython/blob/3ca93ab198497da9451101019b67c52e7873377d/Modules/_interpchannelsmodule.c#L920-L926\n\nLater we check for errors in `handle_channel_error`, it requires either setting `err` to non `-1` or to set Python exception. Both are false, it fails with the assertion failure.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-151127\n* gh-151134\n* gh-151135\n* gh-151136\n* gh-151137\n* gh-151154\n* gh-151180\n* gh-151181\n* gh-151182\n* gh-151239\n* gh-151265\n* gh-151266\n* gh-151336\n* gh-151338\n* gh-151339\n* gh-151360\n* gh-151361\n* gh-151362\n* gh-151382\n* gh-151398\n* gh-151399\n* gh-151400\n* gh-151580\n* gh-151582\n* gh-151588\n* gh-151590\n* gh-151624\n* gh-151639\n* gh-152014\n* gh-152015\n* gh-152016\n* gh-152169\n* gh-152170\n* gh-152177\n* gh-152179\n* gh-152180\n* gh-152181\n* gh-152182\n* gh-152183\n* gh-152184\n* gh-152418\n* gh-152420\n* gh-152421\n* gh-152422\n* gh-152478\n* gh-152677\n* gh-152678\n* gh-152720\n* gh-153215\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2026-06-09T06:32:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/151126/cpython/issues/151126"}
| 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:d591370b-65ce-9f61-03f4-a0cae8f7260e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C00:1D1D40:187398:210EE8:6A517369 |
| html-safe-nonce | cd938367d9412b2ded6b0f8d8013f7ce78ea43f6eaeffbfc87fc9c0a91004d2b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzAwOjFEMUQ0MDoxODczOTg6MjEwRUU4OjZBNTE3MzY5IiwidmlzaXRvcl9pZCI6IjcyNzI3MjYzNDIzODIyMjAxMzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d200b02a41c1f5b8434c3df2e7a5fb3fd80b4966926b30824e29a93c61a0ee03 |
| hovercard-subject-tag | issue:4619485083 |
| 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/151126/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5b1b9a85d74c08326c53d5f47cdeb46358485cc10d56d5de49be62c931e76cf3/python/cpython/issues/151126 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5b1b9a85d74c08326c53d5f47cdeb46358485cc10d56d5de49be62c931e76cf3/python/cpython/issues/151126 |
| og:image:alt | Crash report remove_unused_consts in Python/flowgraph.c When PyMem_Malloc(nconsts * sizeof(Py_ssize_t)); fails, we need to set an exception. cpython/Python/flowgraph.c Lines 3267 to 3283 in 29a920e... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | b19955a9dd40fd99462443f7911b522d7216776a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width