uutils/coreutils · error · io::Error

memory allocation failed

Error message

memory allocation failed

What it means

Error "memory allocation failed" thrown in uutils/coreutils.

Source

Thrown at src/uucore/src/lib/features/sum.rs:83

    fn output_bits(&self) -> usize;
    fn output_bytes(&self) -> usize {
        self.output_bits().div_ceil(8)
    }

    fn result(&mut self) -> io::Result<DigestOutput> {
        let mut buf: Vec<u8> = Vec::new();
        try_reserve_zeroed(&mut buf, self.output_bytes())?;
        self.hash_finalize(&mut buf);
        Ok(DigestOutput::Vec(buf))
    }
}

/// Grows `buf` to `len` zero bytes, returning an [`io::Error`] with
/// [`io::ErrorKind::OutOfMemory`] instead of aborting the process if the
/// allocation can't be satisfied (e.g. an absurdly large `--length`, #12869).
fn try_reserve_zeroed(buf: &mut Vec<u8>, len: usize) -> io::Result<()> {
    buf.try_reserve_exact(len)
        .map_err(|e| io::Error::new(io::ErrorKind::OutOfMemory, e))?;
    buf.resize(len, 0);
    Ok(())
}

/// first element of the tuple is the blake2b state
/// second is the number of output bits
pub struct Blake2b {
    digest: blake2b_simd::State,
    bit_size: usize,
}

impl Blake2b {
    pub const DEFAULT_BYTE_SIZE: usize = 64;
    pub const DEFAULT_BIT_SIZE: usize = Self::DEFAULT_BYTE_SIZE * 8;

    /// Return a new Blake2b instance with a custom output bytes length
    pub fn with_output_bytes(output_bytes: usize) -> Self {
        debug_assert!(

View on GitHub (pinned to 0b77ced485)

Solutions

  1. Free system memory or process smaller inputs so the allocation can succeed.
  2. Check for integer overflow in the size computation that produced the huge allocation.

When it happens

Trigger: Occurs when a memory allocation in the sum (hash) feature fails, typically under memory pressure.

Common situations: Hashing very large inputs or running on systems with exhausted memory or restrictive limits.


AI-assisted analysis of uutils/coreutils@0b77ced485 (2026-08-19). Data as JSON: /api/errors/c9e2b262bc6e7e30. Report an issue: GitHub.