Potential Integer Overflow in mark_stacks function
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
There is a potential signed integer overflow in the expression:
https://github.com/python/cpython/blob/132b6bc98f47a4d897dead8635b5a50a0baee485/Objects/frameobject.c#L1365
This occurs in the loop:
https://github.com/python/cpython/blob/132b6bc98f47a4d897dead8635b5a50a0baee485/Objects/frameobject.c#L1329
len is derived from a Py_SIZE cast, and it can possibly be INT_MAX:
https://github.com/python/cpython/blob/132b6bc98f47a4d897dead8635b5a50a0baee485/Objects/frameobject.c#L1728-L1730
It means that sum can theoretically exceed INT_MAX if len is near the limit, triggering undefined behavior due to signed integer overflow.
Linked PRs
- gh-132773
- gh-132830
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 Objects/frameobject.c at mark_stacks, especially the loop around line 1329 and the expression near line 1365; trace how len is derived at lines 1728-1730. Done means the calculation no longer permits signed overflow when len approaches INT_MAX, with the behavior checked against the linked PRs gh-132773 and gh-132830.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100