oven-sh/bun · warning · bun_exe_format::pe::Error

InsufficientSpace

Error message

InsufficientSpace

What it means

A declared 'not enough space' variant of the PE-manipulation error enum (src/exe_format/pe.rs:39-40). Grep shows no construction site anywhere in the workspace — space checks in pe.rs use the more specific InsufficientHeaderSpace, OutOfBounds and Overflow variants instead. It exists for API completeness/exhaustive matching of bun_exe_format::pe::Error.

Source

Thrown at src/exe_format/pe.rs:39

    #[error("InvalidPESignature")]
    InvalidPESignature,
    #[error("UnsupportedPEFormat")]
    UnsupportedPEFormat,
    #[error("InsufficientHeaderSpace")]
    InsufficientHeaderSpace,
    #[error("TooManySections")]
    TooManySections,
    #[error("SectionExists")]
    SectionExists,
    #[error("InputIsSigned")]
    InputIsSigned,
    #[error("InvalidSecurityDirectory")]
    InvalidSecurityDirectory,
    #[error("SecurityDirInsideImage")]
    SecurityDirInsideImage,
    #[error("UnexpectedOverlayPresent")]
    UnexpectedOverlayPresent,
    #[error("InsufficientSpace")]
    InsufficientSpace,
}

/// Windows PE Binary manipulation for codesigning standalone executables
pub struct PEFile {
    pub(crate) data: Vec<u8>,
    // Store offsets instead of pointers to avoid invalidation after resize
    pub(crate) pe_header_offset: usize,
    pub(crate) optional_header_offset: usize,
    pub(crate) section_headers_offset: usize,
    pub(crate) num_sections: u16,
}

// PE/COFF on-disk header structs are byte-packed (no padding) per spec, and may
// live at arbitrary byte offsets inside a `Vec<u8>` image, so `align_of` must be 1
// for it to be sound to materialize references/pointers to them from the buffer.
#[repr(C, packed)]
#[derive(Copy, Clone)]

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. If it appears in a match, map it to the same handling as InsufficientHeaderSpace/OutOfBounds (free header slack or replace the base).
  2. If you believe you saw it at runtime, you are likely on an old Bun — upgrade and re-test with the stock base exe.
  3. Report a bug with the base executable attached if a current build genuinely produces it.
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Not thrown by any current code path. You can still observe it as a value when pattern-matching the enum in downstream Rust code, or in older Bun builds whose injector used it as a catch-all space error.

Common situations: Writing `match` arms over the error enum (the compiler forces you to handle it); reading old release notes/logs where it was produced during .bun section injection on space-starved PEs.

Related errors


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