Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upBetter handle increasing vector size near usize::MAX #23849
Conversation
added some commits
Mar 29, 2015
rust-highfive
assigned
pcwalton
Mar 29, 2015
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
This comment has been minimized.
This comment has been minimized.
|
I believe the largest allocation we fundamentally support is |
This comment has been minimized.
This comment has been minimized.
|
Are you sure? In the current version of the source https://github.com/rust-lang/rust/blob/master/src/libcollections/vec.rs there's a lot of code that acts like usize::MAX is the max allowed, eg lines 209, 309, 337, 643, 655, 716, 1232. If isize::MAX is the max allowed allocation then there are a lot of changes needed. Though these other lines could be handled in a different PR. (Also doesn't restricting to isize::MAX seem a bit limiting on 32 bit and smaller architectures?) |
This comment has been minimized.
This comment has been minimized.
|
I guess |
This comment has been minimized.
This comment has been minimized.
|
Gotcha, sounds good. I'll fix these instances up tomorrow, would you like me to include the other parts of the file I found above in this PR as well, or submit a different one? |
This comment has been minimized.
This comment has been minimized.
|
Made these locations max out as isize::MAX. I added a fixme comment to fix the rest of the file to also assume isize::MAX is the max size, I'll fix those as well after the PR. |
This comment has been minimized.
This comment has been minimized.
|
r? @pnkfelix |
rust-highfive
assigned
pnkfelix
and unassigned
pcwalton
Apr 1, 2015
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added a commit
that referenced
this pull request
Apr 12, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
That compile failure is ... worrisome. I wonder if a bug has been injected very recently |
This comment has been minimized.
This comment has been minimized.
|
Or maybe I misunderstood a recent discussion of how general unary |
This comment has been minimized.
This comment has been minimized.
|
(The workaround should be easy, in any case,.. use |
This comment has been minimized.
This comment has been minimized.
|
(or wait, maybe this is just an issue where the |
This comment has been minimized.
This comment has been minimized.
|
Yeah it compiled and the tests passed... Not sure what the problem is. |
This comment has been minimized.
This comment has been minimized.
|
I just checked again on my local version, whose most recent commit is commit fa3d778 and it compiles with no problem. So it does appear to be a recent bug. |
This comment has been minimized.
This comment has been minimized.
|
Ah nvm. The problem wasn't introduced. I had compiled/tested with make check-stage1-collections NO_REBUILD=1 NO_BENCH=1 However when I just do a full make, it fails on stage0. So it looks like this is a case of the older version of the compiler which builds stage0 not supporting it. I'll push a fix shortly. |
ghost commentedMar 29, 2015
Right now, if the user requests to increase the vector size via reserve() or push_back() and the request brings the attempted memory above usize::MAX, we panic.
With this change there is only a panic if the minimum requested memory that could meet the requirement is above usize::MAX- otherwise it simply requests its largest capacity possible, usize::MAX.