Skip to content
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

bpo-35623: Fix integer overflow when sorting large lists #11380

Merged
merged 3 commits into from
Jan 2, 2019

Conversation

sth
Copy link
Contributor

@sth sth commented Dec 31, 2018

In list_sort_impl() in one case an int i is used to track the number of elements while sorting. With a large list this can lead to an integer overflow. This happens when running test_bigmem with enough memory.

There is already a Py_ssize_t i defined at function scope that is used
for similar loops. By removing the local int i declaration that i from function scope is
used, which has the appropriate type.

https://bugs.python.org/issue35623

There is already a `Py_ssize_t i` defined at function scope that is used
for similar loops. By removing the local `int i` declaration that `i` is
used, which has the appropriate type.
@benjaminp
Copy link
Contributor

It's always nice when you can fix overflows by deleting a line. Thanks!

@miss-islington
Copy link
Contributor

Thanks @sth for the PR, and @benjaminp for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-11401 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 2, 2019
…onGH-11380)

There is already a `Py_ssize_t i` defined at function scope that is used
for similar loops. By removing the local `int i` declaration that `i` is
used, which has the appropriate type.
(cherry picked from commit f8b5344)

Co-authored-by: sth <[email protected]>
@miss-islington
Copy link
Contributor

Sorry, @sth and @benjaminp, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker f8b534477a2a51d85ea1663530f685f805f2b247 3.6

@miss-islington
Copy link
Contributor

Sorry, @sth and @benjaminp, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker f8b534477a2a51d85ea1663530f685f805f2b247 2.7

miss-islington added a commit that referenced this pull request Jan 2, 2019
…1380)

There is already a `Py_ssize_t i` defined at function scope that is used
for similar loops. By removing the local `int i` declaration that `i` is
used, which has the appropriate type.
(cherry picked from commit f8b5344)

Co-authored-by: sth <[email protected]>
@sth sth deleted the sort-list-segfault branch January 2, 2019 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants