jdx/mise · error
malformed fat header in
Error message
malformed fat header in {} What it means
Thrown when a fat (universal) Mach-O header's arch entry table extends past the end of the file: the 20-byte fat_arch entry at index i would be truncated. The big-endian fat header parse refuses to continue with corrupt or truncated archive tables.
Solutions
- Re-download/reinstall the universal binary (`brew reinstall <formula>`).
- Verify with `lipo -info <binary>` that the fat header parses.
- Check the file size against the bottle manifest to detect truncation.
- Patch each thin slice individually with `lipo -thin` if the fat table itself is suspect.
Example fix
// before
patch(&fat_binary, &replacements)?;
// after: validate first
let out = Command::new("lipo").args(["-info"]).arg(&fat_binary).output()?;
if !out.status.success() { anyhow::bail!("corrupt fat header in {}", fat_binary.display()); }
patch(&fat_binary, &replacements)?; Defensive patterns
Strategy: validation
Validate before calling
fn fat_header_fits(content: &[u8]) -> bool {
if content.len() < 8 { return false; }
let nfat = u32::from_be_bytes(content[4..8].try_into().unwrap()) as usize;
8 + nfat * 20 <= content.len()
} Try / catch
if let Err(e) = patch(&fat, &repl) {
if format!("{e}").contains("malformed fat header") {
eprintln!("{} is not a valid universal binary; reinstall", fat.display());
}
} Prevention
- Verify with `lipo -info` before patching universal binaries.
- Check downloaded artifact sizes against manifests.
- Never concatenate or trim fat binaries manually.
When it happens
Trigger: patch iterates nfat_arch entries; `entry + 20 > content.len()` bails. Caused by truncated universal binaries, corrupt nfat_arch counts, or a file whose magic matched the fat magic but whose body was cut short.
Common situations: Interrupted downloads of universal bottles; files concatenated or split incorrectly; patching fat frameworks that were partially copied; disk corruption.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- malformed fat arch in
- malformed load command in
- malformed load command table in
- malformed Mach-O in
- another process is installing the mise notification helper
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/204f010986dbfeb3.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/brew/macho.rs:186
Ok(true)
}
/// Patch load-command path strings in a Mach-O file (thin or fat).
/// Returns whether anything changed.
pub(super) fn patch(content: &mut [u8], replacements: &[Replacement], path: &Path) -> Result<bool> {
if content.len() < 8 {
return Ok(false);
}
let be_magic = u32::from_be_bytes(content[..4].try_into().unwrap());
if be_magic == FAT_MAGIC_BE {
let nfat = u32::from_be_bytes(content[4..8].try_into().unwrap()) as usize;
let mut changed = false;
// collect slice ranges first (fat headers are big-endian)
let mut ranges = vec![];
for i in 0..nfat {
let entry = 8 + i * 20;
if entry + 20 > content.len() {
bail!("malformed fat header in {}", path.display());
}
let offset =
u32::from_be_bytes(content[entry + 8..entry + 12].try_into().unwrap()) as usize;
let size =
u32::from_be_bytes(content[entry + 12..entry + 16].try_into().unwrap()) as usize;
if offset + size > content.len() {
bail!("malformed fat arch in {}", path.display());
}
ranges.push(offset..offset + size);
}
for range in ranges {
changed |= patch_slice(&mut content[range], replacements, path)?;
}
Ok(changed)
} else {
patch_slice(content, replacements, path)
}
}View on GitHub (pinned to 533346cc37)