-
Notifications
You must be signed in to change notification settings - Fork 9
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
Preventing implicit global OOM handling #87
Comments
Does Cargo’s |
Standard library features can be set using the
You only need to do it for the root crate since this overwrites the implicit |
Ah I see. Since it’s a Cargo CLI flag rather than something specified in the |
The basic issue is that in certain contexts it's deemed very important to enforce that all allocation errors are handled explicitly so there are no unanticipated failure modes. For en example of this, see Linus's response in https://lore.kernel.org/lkml/CAHk-=wh_sNLoz84AUUzuqXEsYH35u=8HV3vK-jbRbJ_B-JjGrg@mail.gmail.com/.
The Rust standard library doesn't help help one keep track of errors, because many functions call the global
handle_alloc_error
to abort the thread/program. Note that this affects not only functions dealing with allocated data (Box, Vec, etc.), but also more innocent-looking functions likeslice::sort
, which just allocate temporaries so there's no hint in the type signature.I would like to see the problem solved, but not in a way that just means such programs ignore
alloc
and hand-roll their own abstractions, because I think that would result in unnecessary and tragic ecosystem fragmentation.My tentative plan is just add a enabled-by-default Cargo feature, without which
handle_alloc_error
and friends simply don't exist. I have started implanting that in rust-lang/rust#84266.The text was updated successfully, but these errors were encountered: