{"record":{"id":"606387cc14a2d854","repo":"rust-lang/rust","slug":"archive-member-at-offset-start-with-size-exce","errorCode":null,"errorMessage":"archive member at offset {start} with size {} exceeds archive size {} in `{}`","messagePattern":"archive member at offset (.+?) with size (.+?) exceeds archive size (.+?) in `(.+?)`","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_ssa/src/back/archive.rs","lineNumber":623,"sourceCode":"            }\n            Some((names, rename_suffix))\n        } else {\n            None\n        };\n\n        let mut entries = Vec::new();\n\n        for (entry_name, entry) in self.entries {\n            let data: Box<dyn AsRef<[u8]>> = match entry.source {\n                ArchiveEntrySource::Archive { archive_index, file_range } => {\n                    let src_archive = &self.src_archives[archive_index];\n                    let archive_data = &src_archive.1;\n                    let start = file_range.0 as usize;\n                    let end = start + file_range.1 as usize;\n                    let Some(data) = archive_data.get(start..end) else {\n                        return Err(io_error_context(\n                            \"invalid archive member\",\n                            io::Error::new(\n                                io::ErrorKind::InvalidData,\n                                format!(\n                                    \"archive member at offset {start} with size {} \\\n                                         exceeds archive size {} in `{}`\",\n                                    file_range.1,\n                                    archive_data.len(),\n                                    src_archive.0.display(),\n                                ),\n                            ),\n                        ));\n                    };\n\n                    if entry.kind == ArchiveEntryKind::RustObj\n                        && let Some(sym) = &symbols\n                    {\n                        Box::new(apply_edits(data, &sym.exported, sym.hide, rename.as_ref()))\n                    } else {\n                        Box::new(data)","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_codegen_ssa/src/back/archive.rs#L605-L641","documentation":"Thrown during rlib/staticlib archive construction in rustc_codegen_ssa's ArArchiveBuilder::build_inner. When copying a member from a source archive (a previously built rlib), the member's byte range [start, start+file_range.1) is sliced from the memory-mapped source archive data via archive_data.get(start..end). If the range extends past the mapped data length, .get() returns None and this InvalidData error is constructed. It means the stored file_range metadata is inconsistent with the actual archive size.","triggerScenarios":"Compiling a crate that links against (rlib dep or native static lib) an archive file whose internal member offsets and sizes do not match its actual byte length. The archive_index and file_range were recorded when the source archive was parsed (add_archive / add_rlib / add_native_library), but the underlying file was subsequently truncated, replaced, or corrupted before build_inner reads the member data.","commonSituations":"Concurrent build processes modifying the same rlib; a corrupted or partially downloaded crate registry cache; disk/filesystem corruption; an upstream bug in the object or archive crate that miscalculates member offsets; stale archive from an interrupted previous build that was not cleaned.","solutions":["Run cargo clean (or remove the affected rlib/static archive from target/ and the registry cache) and rebuild — a clean build eliminates stale/truncated files.","If the archive is in the registry cache (~/.cargo/registry/), delete the specific cache entry and let cargo re-download: rm -rf ~/.cargo/registry/cache/*/offending-crate*.rlib.","Check for concurrent build processes writing to the same target/ directory and serialize them.","Run file/objdump/ar t on the suspect archive to verify its integrity and member table consistency.","If the archive is a native static library (.a) provided externally, obtain a fresh copy from the upstream source."],"exampleFix":"# before: stale or corrupt rlib causing the range mismatch\ncargo build  # fails with 'archive member at offset ...'\n# after: clean and rebuild\ncargo clean && cargo build","handlingStrategy":"try-catch","validationCode":"// Before building, verify the integrity of source archives (rlibs).\nuse std::fs;\nuse std::path::Path;\n\nfn verify_archive_integrity(path: &Path) -> Result<(), String> {\n    let metadata = fs::metadata(path).map_err(|e| format!(\"cannot stat {}: {}\", path.display(), e))?;\n    if metadata.len() == 0 {\n        return Err(format!(\"archive {} is empty (0 bytes)\", path.display()));\n    }\n    // Optionally parse with the `object` crate to check member offsets\n    let data = fs::read(path).map_err(|e| format!(\"cannot read {}: {}\", path.display(), e))?;\n    let archive = object::read::archive::ArchiveFile::parse(&data)\n        .map_err(|e| format!(\"archive {} is malformed: {}\", path.display(), e))?;\n    for member in archive.members() {\n        let member = member.map_err(|e| format!(\"bad member in {}: {}\", path.display(), e))?;\n        let _ = member.data(&data).map_err(|e| format!(\"member data out of bounds in {}: {}\", path.display(), e))?;\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"// The archive build error surfaces as a rustc fatal diagnostic (ArchiveBuildFailure).\n// There is no Rust-level try-catch; the compiler aborts. Prevent it by:\n// 1. Cleaning the build: cargo clean\n// 2. Re-downloading corrupt registry rlibs\n// The error propagates from ArArchiveBuilder::build -> sess.dcx().emit_fatal\n// which terminates compilation. Handle it operationally, not in code.","preventionTips":["Run cargo clean after updating toolchain versions to avoid stale rlib corruption.","If using a shared/network cache (sccache, cargo cache), periodically verify integrity.","Avoid running multiple cargo invocations concurrently against the same target/ directory.","Monitor disk health — filesystem corruption is a leading cause of archive truncation."],"tags":["rustc","archive","rlib","codegen","io","corruption"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}