GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JIT hang in `xml.etree.iterparse` · Issue #149481 · python/cpython

JIT hang in xml.etree.iterparse #149481

New issue
Copy link
New issue
Copy link
Closed
Closed
JIT hang in xml.etree.iterparse#149481
Copy link
Labels
3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@savannahostrowski
savannahostrowski
opened on May 7, 2026
Issue body actions

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 the bm_xml_etree.iterparse benchmark on JIT builds.

A minimum reproducer:

import io
import xml.etree.ElementTree as ET

data = b"<r>" + b"<a/>" * 1000 + b"</r>"

for _ in range(200):
    for event, elem in ET.iterparse(io.BytesIO(data)):
        pass

After bisecting, it looks like this was introduced by #148745. I'm not sure about the exact mechanism, but two observations that may or may not be related:

  • The iterator returned by xml.etree.iterparse has tp_iternext == slot_tp_iternext.
  • The new specialization in Python/optimizer_bytecodes.c excludes PyGen_Type but doesn't have a corresponding exclusion for the slot_tp_iternext case:
if (type != NULL && type != &PyGen_Type && type->tp_iternext != NULL) {
    ...
    ADD_OP(_ITER_NEXT_INLINE, 0, (uintptr_t)type->tp_iternext);
}

Empirically, 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.

Would appreciate a closer look from someone who knows the trace semantics here.

cc: @markshannon @NekoAsakura

Linked PRs

  • gh-149481: skip FOR_ITER inline specialization for Python __next__ #149491
  • [3.15] gh-149481: skip FOR_ITER inline specialization for Python __next__ (GH-149491) #149523
Reacted by Neko Asakura

Activity

  1. savannahostrowski
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-JIT
    3.15bugs and security fixesbugs and security fixes
    on May 7, 2026
  2. StanFromIreland
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on May 7, 2026
  3. NekoAsakura
    added a commit that references this issue on May 7, 2026

    pythongh-149481: skip `FOR_ITER` inline specialization for Python `__…

    9c4bbc8
  4. markshannon commented on May 7, 2026

    @markshannon
    markshannon
    on May 7, 2026
    Member
    More actions

    The fix is correct and we should merge it, but even without this fix, the program shouldn't hang. So we'll need to investigate further.

    Reacted by Savannah Ostrowski and Neko Asakura
  5. savannahostrowski
    added a commit that references this issue on May 7, 2026

    Merge branch 'main' into pythongh-149481/skip-slot-iternext

    71a8e7b
  6. NekoAsakura
    added a commit that references this issue on May 7, 2026

    Merge branch 'main' into pythongh-149481/skip-slot-iternext

    340f5da
  7. StanFromIreland
    added a commit that references this issue on May 7, 2026

    Merge branch 'main' into pythongh-149481/skip-slot-iternext

    682db92
  8. savannahostrowski
    added 2 commits that reference this issue on May 7, 2026

    Merge branch 'main' into pythongh-149481/skip-slot-iternext

    80dd159

    gh-149481: skip `FOR_ITER` inline specialization for Python `__next__` (

    49918f5
  9. savannahostrowski
    closed this as completedon May 7, 2026
  10. savannahostrowski
    added a commit that references this issue on May 8, 2026

    [3.15] gh-149481: skip `FOR_ITER` inline specialization for Python `_…

    5cb915d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.