jdx/mise · error
malformed fat arch in
Error message
malformed fat arch in {} What it means
Thrown when a fat header's arch entry declares an offset+size range that extends past the end of the file. Each fat_arch entry's slice must lie entirely within the file; otherwise the universal binary is corrupt and patching is refused.
Solutions
- Reinstall the formula or re-lipo the binary from valid thin slices (`lipo -create`).
- Validate each arch slice with `lipo -detailed_info` before patching.
- Reject binaries whose fat ranges do not fit within the file.
- Rebuild the fat binary with correct offsets using `lipo` instead of manual concatenation.
Example fix
// before: trust offsets
let ranges = read_fat_ranges(&content);
// after: bounds-check each entry
for r in read_fat_ranges(&content) {
if r.end > content.len() { anyhow::bail!("fat arch out of bounds"); }
}
let ranges = read_fat_ranges(&content); Defensive patterns
Strategy: validation
Validate before calling
fn arch_ranges_valid(content: &[u8]) -> bool {
let nfat = u32::from_be_bytes(content[4..8].try_into().unwrap()) as usize;
(0..nfat).all(|i| {
let e = 8 + i * 20;
let off = u32::from_be_bytes(content[e+8..e+12].try_into().unwrap()) as usize;
let size = u32::from_be_bytes(content[e+12..e+16].try_into().unwrap()) as usize;
off + size <= content.len()
})
} Try / catch
match patch(&fat, &repl) {
Err(e) if format!("{e}").contains("malformed fat arch") => {
// rebuild the fat binary from thin slices instead
eprintln!("bad fat entry; recreate with lipo -create");
}
other => other?,
} Prevention
- Use `lipo` to build universal binaries so offsets are recomputed correctly.
- Run `lipo -detailed_info` to validate entries before patching.
- Reject binaries whose size does not cover all declared arch ranges.
When it happens
Trigger: After reading offset and size (big-endian) from the fat_arch entry, `offset + size > content.len()` bails. Caused by stale offsets after files were modified, wrong nfat counts, truncation, or hand-assembled fat binaries with bad entries.
Common situations: Binaries rebuilt/concatenated by custom scripts without recomputing offsets; partially downloaded bottles; tools that appended/prepended data without updating the fat table.
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 header 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/8ad53328e1d7998e.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/brew/macho.rs:193
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)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::system::packages::brew::relocate::tests::test_replacements;
/// build a minimal 64-bit Mach-O: header + LC_SEGMENT_64 (one section)View on GitHub (pinned to 533346cc37)