Skip to content

Fallible allocations? #484

@kornelski

Description

@kornelski

Is there any chance of making Bytes support fallible allocations? e.g. try_reserve()? This can be done on stable using allocator APIs.

Contrary to a popular belief, Rust can run out of memory, and a crash in hyper/h1 that uses BytesMut is one that I can't fix myself:

frame #4: 0x000055ed3d75e1fe proxy`rust_oom at alloc.rs:331
frame #5: 0x000055ed3d777997 proxy`__rg_oom at alloc.rs:409
frame #6: 0x000055ed3d777987 proxy`alloc::alloc::handle_alloc_error::hff9c7b75d4b02d59 at alloc.rs:363
frame #7: 0x000055ed3d6df552 proxy`alloc::raw_vec::RawVec$LT$T$C$A$GT$::reserve::hf9df86148f278508 [inlined] alloc::raw_vec::handle_reserve::h852aba6b1ef87537 at raw_vec.rs:515
frame #8: 0x000055ed3d6df544 proxy`alloc::raw_vec::RawVec$LT$T$C$A$GT$::reserve::hf9df86148f278508 at raw_vec.rs:311
frame #9: 0x000055ed3d6def01 proxy`bytes::bytes_mut::BytesMut::reserve_inner::ha538bdeb84ed3317 [inlined] alloc::vec::Vec$LT$T$GT$::reserve::hbcc72a1bb27b195d at vec.rs:505
frame #10: 0x000055ed3d6deef6 proxy`bytes::bytes_mut::BytesMut::reserve_inner::ha538bdeb84ed3317 at bytes_mut.rs:584
frame #11: 0x000055ed3ce62068 proxy`hyper::proto::h1::io::Buffered$LT$T$C$B$GT$::poll_read_from_io::h10aec5e55317b2ff [inlined] bytes::bytes_mut::BytesMut::reserve::h1bae842ad2da6364 at bytes_mut.rs:548
frame #12: 0x000055ed3ce6205f proxy`hyper::proto::h1::io::Buffered$LT$T$C$B$GT$::poll_read_from_io::h10aec5e55317b2ff at io.rs:189

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions