Skip to content

bubble up out-of-memory errors from liballoc #18406

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

Merged
merged 1 commit into from
Nov 2, 2014
Merged

bubble up out-of-memory errors from liballoc #18406

merged 1 commit into from
Nov 2, 2014

Conversation

thestinger
Copy link
Contributor

This makes the low-level allocation API suitable for use cases where
out-of-memory conditions need to be handled.

Closes #18292

[breaking-change]

@rust-highfive
Copy link
Contributor

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

if buf.is_null() { panic!("out of memory") }
=======
Copy link
Contributor

Choose a reason for hiding this comment

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

That seems bad

@huonw
Copy link
Member

huonw commented Nov 1, 2014

This needs a rebase, also, the documentation of alloc explicitly states:

This is the lowest level library through which allocation in Rust can be performed where the allocation is assumed to succeed. This library will abort the process when allocation fails.

So this needs to be updated, and maybe the design decision for this choice should be addressed. (git blame implies @alexcrichton wrote that piece of documentation.)

This makes the low-level allocation API suitable for use cases where
out-of-memory conditions need to be handled.

Closes #18292

[breaking-change]
@thestinger
Copy link
Contributor Author

@huonw: It's wrong because reallocate_inplace doesn't abort on failure. It wasn't a design decision but rather an existing assumption that I had to uphold when I wrote originally wrote this code.

@thestinger
Copy link
Contributor Author

There's still not much you can do if you intend to handle out-of-memory conditions, but we can work towards moving the problem further up the stack to make Rust more usable in niches like kernels. For example, there's no reason that Box<T> and Rc<T> couldn't expose a way to handle out-of-memory.

bors added a commit that referenced this pull request Nov 2, 2014
This makes the low-level allocation API suitable for use cases where
out-of-memory conditions need to be handled.

Closes #18292

[breaking-change]
@bors bors closed this Nov 2, 2014
@bors bors merged commit fea985a into rust-lang:master Nov 2, 2014
@huonw huonw mentioned this pull request Nov 10, 2014
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.

liballoc should bubble up out-of-memory errors
5 participants