{"record":{"id":"d9325d1540539ec9","repo":"rust-lang/rust","slug":"e","errorCode":null,"errorMessage":"{e:?}","messagePattern":"\\{e:\\?\\}","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/tools/coverage-dump/src/llvm_utils.rs","lineNumber":79,"sourceCode":"    ///\n    /// Returns the uncompressed bytes that were read directly or decompressed.\n    pub(crate) fn read_chunk_to_uncompressed_bytes(&mut self) -> anyhow::Result<Cow<'a, [u8]>> {\n        let uncompressed_len = self.read_uleb128_usize()?;\n        let compressed_len = self.read_uleb128_usize()?;\n\n        if compressed_len == 0 {\n            // The bytes are uncompressed, so read them directly.\n            let uncompressed_bytes = self.read_n_bytes(uncompressed_len)?;\n            Ok(Cow::Borrowed(uncompressed_bytes))\n        } else {\n            // The bytes are compressed, so read and decompress them.\n            let compressed_bytes = self.read_n_bytes(compressed_len)?;\n\n            let uncompressed_bytes = miniz_oxide::inflate::decompress_to_vec_zlib_with_limit(\n                compressed_bytes,\n                uncompressed_len,\n            )\n            .map_err(|e| anyhow!(\"{e:?}\"))?;\n            ensure!(uncompressed_bytes.len() == uncompressed_len);\n\n            Ok(Cow::Owned(uncompressed_bytes))\n        }\n    }\n}\n","sourceCodeStart":61,"sourceCodeEnd":86,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/tools/coverage-dump/src/llvm_utils.rs#L61-L86","documentation":"Thrown by read_chunk_to_uncompressed_bytes when miniz_oxide fails to zlib-inflate a compressed coverage data chunk up to the recorded uncompressed length. The error is the Debug representation of miniz_oxide's DecompressError (e.g. TINFLStatus::Failed/AdlerMismatch). It signals the on-disk coverage record is internally inconsistent or corrupted.","triggerScenarios":"Invoked when coverage-dump reads an LLVM coverage instrumentation chunk whose header declares a non-zero compressed_len, then decompress_to_vec_zlib_with_limit returns Err. Happens when the .profraw/.llvm-cov artifact was produced by a mismatched LLVM version, truncated by a crashed build, or read from a partially-written file.","commonSituations":"Mixing coverage artifacts between different rustc/LLVM versions; running coverage-dump against a file that is still being written by the compiler; bit-rot on cached coverage data; reading a non-coverage binary that happens to start with a plausible chunk header.","solutions":["Regenerate the coverage artifact with the same toolchain that produced it (re-run the instrumented binary, then re-export).","Verify the file is fully written and not truncated (compare size against writer-side expectations).","Confirm the LLVM version embedded in the coverage data matches the llvm-tools/coverage-dump build; rebuild coverage-dump against the matching LLVM.","If decompressing manually, check the zlib adler32/CRC to localize corruption."],"exampleFix":"// before: assume any compressed chunk is valid\nlet bytes = miniz_oxide::inflate::decompress_to_vec_zlib_with_limit(\n    compressed_bytes, uncompressed_len,\n).map_err(|e| anyhow!(\"{e:?}\"))?;\n\n// after: surface a richer, version-aware error\nlet bytes = miniz_oxide::inflate::decompress_to_vec_zlib_with_limit(\n    compressed_bytes, uncompressed_len,\n).map_err(|e| anyhow!(\n    \"failed to decompress coverage chunk: {e:?} \\\n     (uncompressed_len={uncompressed_len}, compressed_len={compressed_len}); \\\n     the artifact may be from an incompatible LLVM/rustc version\"\n))?","handlingStrategy":"validation","validationCode":"// Before invoking coverage-dump on an artifact, sanity-check it is a valid\n// coverage file and fully written:\nfn looks_like_complete_coverage(path: &Path) -> bool {\n    let Ok(md) = std::fs::metadata(path) else { return false; };\n    md.len() > 0 && !path.ends_with(\".tmp\")\n}\n// Prefer: only process artifacts produced by the same toolchain in one run.","typeGuard":"null","tryCatchPattern":"// Wrap the coverage-dump invocation and report a clear upstream error:\nmatch coverage_dump::dump(&path) {\n    Ok(out) => { /* ... */ }\n    Err(e) if e.to_string().contains(\"decompress\") => {\n        eprintln!(\"{path:?} appears corrupt or from an incompatible LLVM version: {e}\");\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always regenerate coverage artifacts with the same toolchain that built coverage-dump.","Never read coverage files that the instrumented binary is still writing.","Pin the rustc/LLVM version in CI for both producing and consuming coverage data."],"tags":["coverage","llvm","decompression","corruption"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}