Skip to content

Make OOM a lang item #27335

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

Closed
Gankra opened this issue Jul 27, 2015 · 3 comments
Closed

Make OOM a lang item #27335

Gankra opened this issue Jul 27, 2015 · 3 comments

Comments

@Gankra
Copy link
Contributor

Gankra commented Jul 27, 2015

Currently alloc::oom just calls intrinsics::abort making the program look like it faulted, when really we killed it in a controlled manner. The reason it does that is that liballoc only assumes we have an allocator and no other OS/runtime.

However if oom was a lang item, we could implement it only in std, and have it print a message without allocating using

std::rt::abort("Allocator returned out of memory, aborting program")

no_std users could also opt into custom oom hooks, though they still have to crash the program.

We could also potentially add a flag for building std that makes oom unwind instead.

@alexcrichton
Copy link
Member

Sounds like a good plan to me! This would basically use the same infrastructure as panic_fmt and friends.

@steveklabnik
Copy link
Member

Isn't this more of an RFC kinda thing?

@steveklabnik
Copy link
Member

Yes, seems like it would be. Let's go that route, please!

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

No branches or pull requests

3 participants