Title: JIT hang in `xml.etree.iterparse` · Issue #149481 · python/cpython · GitHub
Open Graph Title: JIT hang in `xml.etree.iterparse` · Issue #149481 · python/cpython
X Title: JIT hang in `xml.etree.iterparse` · Issue #149481 · python/cpython
Description: It looks like there's a JIT hang that's been blocking my nightly benchmark runs across all machines for the past two nights (see here and here), as well as @diegorusso's runs on his runner (see here and here). These runs always hang at t...
Open Graph Description: It looks like there's a JIT hang that's been blocking my nightly benchmark runs across all machines for the past two nights (see here and here), as well as @diegorusso's runs on his runner (see her...
X Description: It looks like there's a JIT hang that's been blocking my nightly benchmark runs across all machines for the past two nights (see here and here), as well as @diegorusso's runs on his run...
Opengraph URL: https://github.com/python/cpython/issues/149481
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JIT hang in `xml.etree.iterparse`","articleBody":"It looks like there's a JIT hang that's been blocking my nightly benchmark runs across all machines for the past two nights (see [here](https://github.com/savannahostrowski/pyperf_bench/actions/runs/25443771452) and [here](https://github.com/savannahostrowski/pyperf_bench/actions/runs/25369160867)), as well as @diegorusso's runs on his runner (see [here](https://github.com/diegorusso/pyperf-bench/actions/runs/25413478324) and [here](https://github.com/diegorusso/pyperf-bench/actions/runs/25354872255)).\n\nThese runs always hang at the [bm_xml_etree.iterparse](https://github.com/python/pyperformance/blob/main/pyperformance/data-files/benchmarks/bm_xml_etree/run_benchmark.py) benchmark on JIT builds. \n\nA minimum reproducer:\n```\nimport io\nimport xml.etree.ElementTree as ET\n\ndata = b\"\u003cr>\" + b\"\u003ca/>\" * 1000 + b\"\u003c/r>\"\n\nfor _ in range(200):\n for event, elem in ET.iterparse(io.BytesIO(data)):\n pass\n```\n\nAfter bisecting, it looks like this was introduced by https://github.com/python/cpython/pull/148745. I'm not sure about the exact mechanism, but two observations that may or may not be related:\n\n- The iterator returned by `xml.etree.iterparse` has `tp_iternext` == `slot_tp_iternext`.\n- The new specialization in [Python/optimizer_bytecodes.c](https://github.com/python/cpython/blob/2b7c28a4406da1b26dd0ebd38aa7371bed873ce4/Python/optimizer_bytecodes.c#L1462) excludes `PyGen_Type` but doesn't have a corresponding exclusion for the `slot_tp_iternext` case:\n\n```\nif (type != NULL && type != &PyGen_Type && type->tp_iternext != NULL) {\n ...\n ADD_OP(_ITER_NEXT_INLINE, 0, (uintptr_t)type->tp_iternext);\n}\n```\n\nEmpirically, also excluding the case where `tp_iternext == slot_tp_iternext` makes the hang go away in my local builds, but I don't know whether that's the real fix or just an incidental one that happens to side-step the trigger.\n\nWould appreciate a closer look from someone who knows the trace semantics here.\n\ncc: @markshannon @NekoAsakura \n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-149491\n* gh-149523\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/savannahostrowski","@type":"Person","name":"savannahostrowski"},"datePublished":"2026-05-07T03:55:14Z","url":"https://github.com/python/cpython/issues/149481"}
| 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:7e3761e5-b7b0-7291-eb07-39ef9c6aafdd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 886C:380435:1F5D7D:27E34B:6B01F33D |
| html-safe-nonce | 43aef594f74b7595ce70bf94b32ce53cec7b99f745e36b46f0a036aaec3ab3dd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODZDOjM4MDQzNToxRjVEN0Q6MjdFMzRCOjZCMDFGMzNEIiwidmlzaXRvcl9pZCI6IjQ1Nzc5NTY4NjQ2NTgxMDkyNDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c684a21fa5c1e359dc2fc4d04c12f5478767b8cae756116eda0d95930f4d3b00 |
| hovercard-subject-tag | issue:4396072334 |
| 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/149481/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fbee4a2e222a718240d787287550cc1fe05c68018d09569f803910f2f5aba8b1/python/cpython/issues/149481 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fbee4a2e222a718240d787287550cc1fe05c68018d09569f803910f2f5aba8b1/python/cpython/issues/149481 |
| og:image:alt | It looks like there's a JIT hang that's been blocking my nightly benchmark runs across all machines for the past two nights (see here and here), as well as @diegorusso's runs on his runner (see her... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | savannahostrowski |
| 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