Title: symtable: NULL dereference after OOM in PyUnicode_FromFormat (symtable_visit_type_param_bound_or_default) · Issue #152682 · python/cpython · GitHub
Open Graph Title: symtable: NULL dereference after OOM in PyUnicode_FromFormat (symtable_visit_type_param_bound_or_default) · Issue #152682 · python/cpython
X Title: symtable: NULL dereference after OOM in PyUnicode_FromFormat (symtable_visit_type_param_bound_or_default) · Issue #152682 · python/cpython
Description: symtable_visit_type_param_bound_or_default in Python/symtable.c calls PyUnicode_FromFormat() to build a SyntaxError message when a type parameter is named __classdict__. The return value is not checked for NULL before being passed to PyE...
Open Graph Description: symtable_visit_type_param_bound_or_default in Python/symtable.c calls PyUnicode_FromFormat() to build a SyntaxError message when a type parameter is named __classdict__. The return value is not che...
X Description: symtable_visit_type_param_bound_or_default in Python/symtable.c calls PyUnicode_FromFormat() to build a SyntaxError message when a type parameter is named __classdict__. The return value is not che...
Opengraph URL: https://github.com/python/cpython/issues/152682
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"symtable: NULL dereference after OOM in PyUnicode_FromFormat (symtable_visit_type_param_bound_or_default)","articleBody":"`symtable_visit_type_param_bound_or_default` in `Python/symtable.c` calls `PyUnicode_FromFormat()` to build a `SyntaxError` message when a type parameter is named `__classdict__`. The return value is not checked for NULL before being passed to `PyErr_SetObject()` and `Py_DECREF()`.\n\nIf `PyUnicode_FromFormat()` fails due to memory exhaustion, `error_msg` is NULL. The subsequent `Py_DECREF(NULL)` is undefined behavior and crashes the interpreter in a release build (NDEBUG).\n\nAffected code (introduced by commit `891c61c`, `gh-128632`):\n```\n// Python/symtable.c\nPyObject *error_msg = PyUnicode_FromFormat(\"reserved name '%U' cannot be \"\n \"used for type parameter\", name);\nPyErr_SetObject(PyExc_SyntaxError, error_msg); // UB if error_msg is NULL\nPy_DECREF(error_msg); // crash if error_msg is NULL\n```\n\n**Trigger condition:** `PyUnicode_FromFormat()` returns NULL while compiling Python source that contains a type parameter named `__classdict__` (e.g. type `T[__classdict__: int] = None`). In normal conditions this requires an OOM event at exactly that point; in constrained environments this is reproducible with ulimit or fault injection.\n\n**Expected behavior:** `MemoryError` is propagated cleanly.\n\n**Actual behavior:** `Py_DECREF(NULL)` --\u003e `SIGSEGV` in release builds; assertion failure in debug builds.\n\nCPython versions tested on: 3.13 (main, 3.13 branch)\n\nOperating systems tested on: Linux Fedora 43\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-152684\n* gh-152695\n* gh-152696\n* gh-152697\n* gh-152770\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/petrvaganoff","@type":"Person","name":"petrvaganoff"},"datePublished":"2026-06-30T13:33:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/152682/cpython/issues/152682"}
| 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:46122180-cdee-8a63-a949-2c8a95820495 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A448:122D73:5C59:72FA:6A512148 |
| html-safe-nonce | ca8b7c76aca03b352294e6367dce5164cd63bfbd03d3fb74274ee3fa5ebb6e4a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDQ4OjEyMkQ3Mzo1QzU5OjcyRkE6NkE1MTIxNDgiLCJ2aXNpdG9yX2lkIjoiMzE5NzkzMDk4NDIxNDQzODIxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 291f624f8f5f4e958e7919ddb6cb6e49b7b66a0db314384b20cc8373bea1b7f9 |
| hovercard-subject-tag | issue:4777232882 |
| 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/152682/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a78d8ca19de5e1fc05ba9f18761ca09193a9a3eb7f9bea5f7754df9690d83fa1/python/cpython/issues/152682 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a78d8ca19de5e1fc05ba9f18761ca09193a9a3eb7f9bea5f7754df9690d83fa1/python/cpython/issues/152682 |
| og:image:alt | symtable_visit_type_param_bound_or_default in Python/symtable.c calls PyUnicode_FromFormat() to build a SyntaxError message when a type parameter is named __classdict__. The return value is not che... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | petrvaganoff |
| hostname | github.com |
| expected-hostname | github.com |
| None | 689b683944b0d7f015d0e776452c970832fa81b82dc15284469b556ecced715b |
| 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 | 942b51ed3bd5feee3d5e2719f890a5fe286edbbb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width