FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Handle MemoryError for list and strings. by philippeitis · Pull Request #1779 · RustPython/RustPython · GitHub

Handle MemoryError for list and strings. - #1779

Open
philippeitis wants to merge 4 commits into
RustPython:mainfrom
philippeitis:patch-2
Open

Handle MemoryError for list and strings.#1779
philippeitis wants to merge 4 commits into
RustPython:mainfrom
philippeitis:patch-2

Conversation

philippeitis commented Feb 27, 2020
edited
Loading

Copy link
Copy Markdown
Contributor

This aims to address #1750 by raising a Memory error for excessively large allocations. It adds a MAX_MEMORY_SIZE const to VM which is then used by objlist.rs and objstr.rs when doing imul or mul operations.

Comment thread vm/src/obj/objlist.rs Outdated

Copy link
Copy Markdown
Member

I'm not sure if this is the correct approach; 2**61 bytes is 2.3 exabytes, which probably wouldn't get hit before an actual OOM error occurs in the process. There is a RFC that allows for catching OOMs in a few different ways (try_reserve -> Result<(), ...> functions on Vec or String, oom=panic rustc option that will panic and unwind instead of just aborting) but none of them are stable yet. I'm not sure how to approach this problem, honestly.

Copy link
Copy Markdown
Contributor Author

That is true, but this is also a reasonable sanity check, since a list with 8 byte pointers can only contain up to usize::MAX / 8 elements. Beyond that, allocating becomes the virtual machine's problem and will need to dealt with accordingly.

auvipy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

it would be great if you could rebase it for further review.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL