8000 Handle MemoryError for sequences by crazymerlyn · Pull Request #5418 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Conversation

crazymerlyn
Copy link
Contributor

Fixes #1750

Based on #1779 which seems to be abandoned.

vm/src/vm/mod.rs Outdated
pub(crate) use method::PyMethod;
pub use setting::Settings;

pub const MAX_MEMORY_SIZE: usize = (usize::MAX >> 3) + 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Is this constant came from CPython?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like isize::MAX, since the first s in ssize_t means signed. Which makes sense, since that's the max size an allocation can be for LLVM. I do think we could maybe just use isize::MAX, because otherwise we're unnecessarily constraining allocation size to "just" 512GiB on 32-bit systems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use isize::MAX. Also updated to include the size of the type and fixed the potential integer overflow problem.

@youknowone
Copy link
Member

Added @coolreader18 as a reviewer who reviewed #1779

@crazymerlyn crazymerlyn force-pushed the memoryerror branch 2 times, most recently from 75a03e3 to cf9f036 Compare September 29, 2024 15:20
Copy link
Member
@coolreader18 coolreader18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for contributing!

@coolreader18 coolreader18 merged commit 29d9534 into RustPython:main Sep 29, 2024
11 checks passed
@crazymerlyn crazymerlyn 7669 deleted the memoryerror branch September 29, 2024 15:57
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.

list panic when size > isize::MAX

3 participants

0