oven-sh/bun · error · MachoError

OutOfMemory

Error message

OutOfMemory

What it means

MachoError variant: an allocation needed while growing or rebuilding the Mach-O image (e.g. resizing the buffer for a new __LINKEDIT layout) failed. It is a memory-exhaustion sentinel from the rewriting path, distinct from structural validation errors.

Solutions

  1. Free memory or reduce parallelism in the build environment and retry
  2. Check for an accidental huge allocation caused by corrupt sizes earlier in the parsing path
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/exe_format/macho.rs:30 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/ebcfeb6b04a6a4de. Report an issue: GitHub.

Appendix: source

Thrown at src/exe_format/macho.rs:30

const SECTNAME: [u8; 16] = *b"__bun\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";

#[derive(Debug, Copy, Clone, PartialEq, Eq, thiserror::Error, strum::IntoStaticStr)]
pub enum MachoError {
    #[error("InvalidObject")]
    InvalidObject,
    #[error("MissingLinkeditSegment")]
    MissingLinkeditSegment,
    #[error("OffsetOutOfRange")]
    OffsetOutOfRange,
    #[error("OffsetOverflow")]
    OffsetOverflow,
    #[error("InvalidLinkeditOffset")]
    InvalidLinkeditOffset,
    #[error("OverlappingSegments")]
    OverlappingSegments,
    #[error("MissingRequiredSegment")]
    MissingRequiredSegment,
    #[error("OutOfMemory")]
    OutOfMemory,
}
bun_core::oom_from_alloc!(MachoError);

pub struct MachoFile {
    pub(crate) header: macho::mach_header_64,
    pub(crate) data: Vec<u8>,
    pub(crate) segment: macho::segment_command_64,
    pub(crate) section: macho::section_64,
}

/// Expands to one `shift_one` call per named field.
macro_rules! shift_fields {
    ($shifter:expr, $value:expr, $($field:ident),+ $(,)?) => {{
        $( $shifter.shift_one(&mut $value.$field)?; )+
    }};
}

View on GitHub (pinned to 8c5296ac45)