{"record":{"id":"475306adca6fdc0c","repo":"oven-sh/bun","slug":"overlappingsegments","errorCode":null,"errorMessage":"OverlappingSegments","messagePattern":"OverlappingSegments","errorType":"error_code","errorClass":"MachoError","httpStatus":null,"severity":"error","filePath":"src/exe_format/macho.rs","lineNumber":26,"sourceCode":"\nuse bun_core::env_var::feature_flag;\n\nconst SEGNAME_BUN: [u8; 16] = *b\"__BUN\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\";\nconst SECTNAME: [u8; 16] = *b\"__bun\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\";\n\n#[derive(Debug, Copy, Clone, PartialEq, Eq, thiserror::Error, strum::IntoStaticStr)]\npub enum MachoError {\n    #[error(\"InvalidObject\")]\n    InvalidObject,\n    #[error(\"MissingLinkeditSegment\")]\n    MissingLinkeditSegment,\n    #[error(\"OffsetOutOfRange\")]\n    OffsetOutOfRange,\n    #[error(\"OffsetOverflow\")]\n    OffsetOverflow,\n    #[error(\"InvalidLinkeditOffset\")]\n    InvalidLinkeditOffset,\n    #[error(\"OverlappingSegments\")]\n    OverlappingSegments,\n    #[error(\"MissingRequiredSegment\")]\n    MissingRequiredSegment,\n    #[error(\"OutOfMemory\")]\n    OutOfMemory,\n}\nbun_core::oom_from_alloc!(MachoError);\n\npub struct MachoFile {\n    pub(crate) header: macho::mach_header_64,\n    pub(crate) data: Vec<u8>,\n    pub(crate) segment: macho::segment_command_64,\n    pub(crate) section: macho::section_64,\n}\n\n/// Expands to one `shift_one` call per named field.\nmacro_rules! shift_fields {\n    ($shifter:expr, $value:expr, $($field:ident),+ $(,)?) => {{","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/exe_format/macho.rs#L8-L44","documentation":"MachoError variant: two segments in the Mach-O have overlapping file-offset or address ranges. The writer relies on disjoint segments when inserting/moving content; overlap means the binary's layout is invalid or was mangled by post-link tooling, and any patch would corrupt one of the segments.","triggerScenarios":"Thrown at src/exe_format/macho.rs:26 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rebuild the executable from a clean link so segments do not overlap","Audit any post-processing steps (strip, signing, compression) that may have rewritten segment ranges"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","contentChangedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}