Crash in `create_elementiter` when OOM
Open
Nobody has claimed this yet.
extension-modules
topic-XML
type-crash
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
Linked PRs
- gh-148838
- gh-152120
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Modules/_elementtree.c around create_elementiter and reproduce the reported e.iter() case with _testcapi.set_nomemory under UBSan. Review linked PRs gh-148838 and gh-152120; done means the out-of-memory path no longer triggers the null-pointer offset diagnostic or segmentation fault.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100