Skip to content

Potential integer overflow in instrumentation.c #135177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rialbat opened this issue Jun 5, 2025 · 1 comment
Open

Potential integer overflow in instrumentation.c #135177

rialbat opened this issue Jun 5, 2025 · 1 comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@rialbat
Copy link
Contributor

rialbat commented Jun 5, 2025

The arithmetic expression to * (int)sizeof(_Py_CODEUNIT) can overflow if the number of instructions in a function exceeds MAX_INT / 2, as to represents the instruction offset and sizeof(_Py_CODEUNIT) is 2.

PyObject *to_obj = PyLong_FromLong(to * (int)sizeof(_Py_CODEUNIT));

Linked PRs

rialbat added a commit to rialbat/cpython that referenced this issue Jun 5, 2025
@tomasr8 tomasr8 added the type-bug An unexpected behavior, bug, or error label Jun 6, 2025
rialbat added a commit to rialbat/cpython that referenced this issue Jun 6, 2025
@ZeroIntensity ZeroIntensity added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jun 6, 2025
rialbat added a commit to rialbat/cpython that referenced this issue Jun 6, 2025
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
rialbat added a commit to rialbat/cpython that referenced this issue Jun 6, 2025
Clarified that we are referring to the int type in C.

Co-authored-by: Victor Stinner <vstinner@python.org>
rialbat added a commit to rialbat/cpython that referenced this issue Jun 6, 2025
…ential overflow

Co-authored-by: Victor Stinner <vstinner@python.org>
rialbat added a commit to rialbat/cpython that referenced this issue Jun 6, 2025
… to Py_ssize_t for type consistency in assert

Co-authored-by: Victor Stinner <vstinner@python.org>
@markshannon
Copy link
Member

The number of instructions will not exceed MAX_INT / 2, the bytecode compiler ensures that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants