hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.42k stars 1.59k forks source link

Provide way to catch OOM in C API #2396

Open seanmonstar opened 3 years ago

seanmonstar commented 3 years ago

Currently, allocation errors automatically result in an abort, which is undesirable in the C API. We could look into using std::alloc::set_alloc_error_hook or similar, to override the default behavior so that it doesn't abort, but does some sort of panic!(HyperOom), and we catch that at the FFI boundary (like all panics). However, that is not a stable function. First step is likely to get libstd to stabilize something we can use.

Originally from https://github.com/hyperium/hyper/issues/2265#issuecomment-694508481

seanmonstar commented 3 years ago

As a check-in (at least for myself), there's the following tracking issues for the lang/libstd:

The status of those issues don't seem to have changed. It may need more active attention from us.