Title: Missing `PyErr_NoMemory` in `_zoneinfo` `load_data` and `ts_to_local` · Issue #146092 · python/cpython · GitHub
Open Graph Title: Missing `PyErr_NoMemory` in `_zoneinfo` `load_data` and `ts_to_local` · Issue #146092 · python/cpython
X Title: Missing `PyErr_NoMemory` in `_zoneinfo` `load_data` and `ts_to_local` · Issue #146092 · python/cpython
Description: Crash report What happened? It's possible to cause assertion errors due to calls returning NULL on OOM in _zoneinfo. Automated diagnosis: Multiple PyMem_Malloc/PyMem_Calloc calls in load_data (including ts_to_local at line 2130) return N...
Open Graph Description: Crash report What happened? It's possible to cause assertion errors due to calls returning NULL on OOM in _zoneinfo. Automated diagnosis: Multiple PyMem_Malloc/PyMem_Calloc calls in load_data (incl...
X Description: Crash report What happened? It's possible to cause assertion errors due to calls returning NULL on OOM in _zoneinfo. Automated diagnosis: Multiple PyMem_Malloc/PyMem_Calloc calls in load_data (...
Opengraph URL: https://github.com/python/cpython/issues/146092
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Missing `PyErr_NoMemory` in `_zoneinfo` `load_data` and `ts_to_local`","articleBody":"# Crash report\n\n### What happened?\n\nIt's possible to cause assertion errors due to calls returning `NULL` on OOM in `_zoneinfo`.\n\n### Automated diagnosis:\n\nMultiple `PyMem_Malloc`/`PyMem_Calloc` calls in `load_data` (including `ts_to_local` at line 2130) return `NULL` on OOM and goto `error` without setting an exception. The caller returns `NULL` without exception → assertion failure.\n\nFile: `Modules/_zoneinfo.c`, lines 1029-1137 (`load_data`), 2130 (`ts_to_local`)\n\nMRE for `load_data`:\n```python\nimport _testcapi, sys\n\nfor mod in [\"zoneinfo\", \"_zoneinfo\"]:\n if mod in sys.modules:\n del sys.modules[mod]\n\nfor n in range(1, 50):\n for mod in [\"zoneinfo\", \"_zoneinfo\"]:\n if mod in sys.modules:\n del sys.modules[mod]\n print(n)\n _testcapi.set_nomemory(n, 0)\n try:\n from zoneinfo import ZoneInfo\n z = ZoneInfo(\"UTC\")\n _testcapi.remove_mem_hooks()\n break\n except MemoryError:\n _testcapi.remove_mem_hooks()\n```\n\nMRE for `ts_to_local`:\n```python\nimport _testcapi\nfrom zoneinfo import ZoneInfo\n\n# Warm up imports — we only want OOM during zone construction\n_ = ZoneInfo(\"UTC\")\ndel _\n\n# Clear cache so America/New_York gets re-loaded from TZif data\nZoneInfo.clear_cache()\n\n# Persistent failure from allocation #9 onward.\n# Early allocs (import machinery, arg parsing) succeed;\n# the PyMem_Malloc in load_data/ts_to_local fails.\n_testcapi.set_nomemory(9, 0)\n\nz = ZoneInfo(\"America/New_York\") # crashes: assertion `obj != NULL'\n```\n\nBacktrace:\n```\npython: ./Include/internal/pycore_stackref.h:554: _PyStackRef PyStackRef_FromPyObjectSteal(PyObject *): Assertion `obj != NULL' failed.\n\nProgram received signal SIGABRT, Aborted.\n\n#0 __pthread_kill_implementation (threadid=\u003coptimized out\u003e, signo=6, no_tid=0) at ./nptl/pthread_kill.c:44\n#1 __pthread_kill_internal (threadid=\u003coptimized out\u003e, signo=6) at ./nptl/pthread_kill.c:89\n#2 __GI___pthread_kill (threadid=\u003coptimized out\u003e, signo=signo@entry=6) at ./nptl/pthread_kill.c:100\n#3 0x00007ffff7c45e2e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26\n#4 0x00007ffff7c28888 in __GI_abort () at ./stdlib/abort.c:77\n#5 0x00007ffff7c287f0 in __assert_fail_base (fmt=\u003coptimized out\u003e, assertion=\u003coptimized out\u003e, file=\u003coptimized out\u003e, line=\u003coptimized out\u003e, function=\u003coptimized out\u003e) at ./assert/assert.c:118\n#6 0x00007ffff7c3c19f in __assert_fail (assertion=\u003coptimized out\u003e, file=\u003coptimized out\u003e, line=\u003coptimized out\u003e, function=\u003coptimized out\u003e) at ./assert/assert.c:127\n#7 0x000055555587fd55 in PyStackRef_FromPyObjectSteal (obj=\u003coptimized out\u003e) at ./Include/internal/pycore_stackref.h:554\n#8 0x0000555555842cd0 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555d99c08 \u003c_PyRuntime+360664\u003e, frame=\u003coptimized out\u003e, frame@entry=0x7ffff7fa70a0, throwflag=throwflag@entry=0)\n at Python/generated_cases.c.h:292\n#9 0x000055555583f08b in _PyEval_EvalFrame (tstate=0x555555d99c08 \u003c_PyRuntime+360664\u003e, frame=0x7ffff7fa70a0, throwflag=0) at ./Include/internal/pycore_ceval.h:118\n#10 _PyEval_Vector (tstate=0x555555d99c08 \u003c_PyRuntime+360664\u003e, func=0x7ffff75e9190, locals=0x0, args=0x7fffffffb310, argcount=2, kwnames=0x0) at Python/ceval.c:2130\n#11 0x00005555556a2ebe in _PyObject_VectorcallTstate (tstate=0x555555d99c08 \u003c_PyRuntime+360664\u003e, callable=callable@entry=0x7ffff75e9190, args=args@entry=0x7fffffffb310,\n nargsf=nargsf@entry=2, kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:144\n#12 0x00005555556a625a in object_vacall (tstate=tstate@entry=0x555555d99c08 \u003c_PyRuntime+360664\u003e, base=base@entry=0x0, callable=callable@entry=0x7ffff75e9190,\n vargs=vargs@entry=0x7fffffffb460) at Objects/call.c:823\n#13 0x00005555556a5f0b in PyObject_CallMethodObjArgs (obj=0x7ffff75b08c0, name=0x555555d57470 \u003c_PyRuntime+88384\u003e) at Objects/call.c:960\n#14 0x000055555595136b in import_find_and_load (tstate=tstate@entry=0x555555d99c08 \u003c_PyRuntime+360664\u003e, abs_name=abs_name@entry=0x7ffff74f86d0) at Python/import.c:4125\n#15 0x0000555555950f66 in PyImport_ImportModuleLevelObject (name=name@entry=0x7ffff74f86d0, globals=globals@entry=0x7ffff746a4b0, locals=locals@entry=0x7ffff746a4b0,\n fromlist=0x7ffff7477cf0, level=level@entry=0) at Python/import.c:4241\n#16 0x00005555558f7265 in _PyEval_ImportNameWithImport (tstate=tstate@entry=0x555555d99c08 \u003c_PyRuntime+360664\u003e, import_func=0x7ffff75be9f0, globals=globals@entry=0x7ffff746a4b0,\n locals=locals@entry=0x7ffff746a4b0, name=name@entry=0x7ffff74f86d0, fromlist=fromlist@entry=0x7ffff7477cf0, level=0x555555d49188 \u003c_PyRuntime+30296\u003e) at Python/ceval.c:2975\n#17 0x00005555558848bf in _PyEval_ImportName (tstate=tstate@entry=0x555555d99c08 \u003c_PyRuntime+360664\u003e, builtins=0x7ffff75be930, globals=0x7ffff746a4b0, locals=0x7ffff746a4b0,\n name=0x7ffff74f86d0, fromlist=0x7ffff7477cf0, level=0x555555d49188 \u003c_PyRuntime+30296\u003e) at Python/ceval.c:2954\n#18 0x000055555586141a in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555d99c08 \u003c_PyRuntime+360664\u003e, frame=\u003coptimized out\u003e, frame@entry=0x7ffff7fa7020, throwflag=throwflag@entry=0)\n at Python/generated_cases.c.h:6460\n#19 0x000055555583f08b in _PyEval_EvalFrame (tstate=0x555555d99c08 \u003c_PyRuntime+360664\u003e, frame=0x7ffff7fa7020, throwflag=0) at ./Include/internal/pycore_ceval.h:118\n#20 _PyEval_Vector (tstate=tstate@entry=0x555555d99c08 \u003c_PyRuntime+360664\u003e, func=func@entry=0x7ffff7466690, locals=locals@entry=0x7ffff746a4b0, args=args@entry=0x0,\n argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:2130\n#21 0x000055555583ee1e in PyEval_EvalCode (co=co@entry=0x555555f3baf0, globals=globals@entry=0x7ffff746a4b0, locals=locals@entry=0x7ffff746a4b0) at Python/ceval.c:686\n#22 0x00005555559c8f8e in run_eval_code_obj (tstate=0x555555d99c08 \u003c_PyRuntime+360664\u003e, co=co@entry=0x555555f3baf0, globals=globals@entry=0x7ffff746a4b0, locals=locals@entry=0x7ffff746a4b0)\n at Python/pythonrun.c:1368\n#23 0x00005555559c8adb in run_mod (mod=mod@entry=0x555555f43b30, filename=filename@entry=0x7ffff74e8580, globals=globals@entry=0x7ffff746a4b0, locals=locals@entry=0x7ffff746a4b0,\n flags=0x7fffffffc950, arena=arena@entry=0x7ffff74dad40, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1471\n```\n\nFound using [cpython-review-toolkit](https://github.com/devdanzin/cpython-review-toolkit) with Claude Opus 4.6, using the `/cpython-review-toolkit:explore Modules/_zoneinfo.c all deep` command.\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n### Output from running 'python -VV' on the command line:\n\nPython 3.15.0a7+ (heads/main:e0f7c1097e1, Mar 17 2026, 18:10:52) [Clang 21.1.2 (2ubuntu6)]\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-146117\n* gh-146119\n* gh-146124\n* gh-146132\n* gh-146138\n* gh-146165\n* gh-146223\n* gh-146224\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/devdanzin","@type":"Person","name":"devdanzin"},"datePublished":"2026-03-17T23:23:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/146092/cpython/issues/146092"}
| 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:9243a2d3-83b1-5569-6344-de88a18de3ce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 991E:28B9FB:160DD59:1F29515:6A50BA2E |
| html-safe-nonce | a081e9b948c808018a9eb8ef3464985424bcc0e26e048617ce25cd893600e0a1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTFFOjI4QjlGQjoxNjBERDU5OjFGMjk1MTU6NkE1MEJBMkUiLCJ2aXNpdG9yX2lkIjoiNDgyNzY4NDU3Njk3NjQ4NDkxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 506081661fcf0832fb4cfb207109319a31cb31e44f019b2ef4172c797e6b00b7 |
| hovercard-subject-tag | issue:4091737007 |
| 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/146092/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3c8ffff2705b0809daf0aa37eb8d12bcbafd687c3f1fc19aa5e12bbc3f9469e3/python/cpython/issues/146092 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3c8ffff2705b0809daf0aa37eb8d12bcbafd687c3f1fc19aa5e12bbc3f9469e3/python/cpython/issues/146092 |
| og:image:alt | Crash report What happened? It's possible to cause assertion errors due to calls returning NULL on OOM in _zoneinfo. Automated diagnosis: Multiple PyMem_Malloc/PyMem_Calloc calls in load_data (incl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devdanzin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| 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 | 08e79d53fc070870d5b168356afebb1e286a2ffe |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width