Skip to content

Crash in create_elementiter when OOM #148731

@StanFromIreland

Description

@StanFromIreland

Crash report

What happened?

import _testcapi
from xml.etree.ElementTree import Element

e = Element('root')

_testcapi.set_nomemory(1, 2)
try:
    e.iter()
except MemoryError:
    pass
finally:
    _testcapi.remove_mem_hooks()

With UBSan enabled, I get:

Modules/_elementtree.c:2176:9: runtime error: applying non-zero offset 15914838024376868032 to null pointer
Segmentation fault         (core dumped)

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Output from running 'python -VV' on the command line:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtopic-XMLtype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions