rust-lang/rust · error · anyhow::Error
{e:?}
Error message
{e:?} What it means
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.
Source
Thrown at src/tools/coverage-dump/src/llvm_utils.rs:79
///
/// Returns the uncompressed bytes that were read directly or decompressed.
pub(crate) fn read_chunk_to_uncompressed_bytes(&mut self) -> anyhow::Result<Cow<'a, [u8]>> {
let uncompressed_len = self.read_uleb128_usize()?;
let compressed_len = self.read_uleb128_usize()?;
if compressed_len == 0 {
// The bytes are uncompressed, so read them directly.
let uncompressed_bytes = self.read_n_bytes(uncompressed_len)?;
Ok(Cow::Borrowed(uncompressed_bytes))
} else {
// The bytes are compressed, so read and decompress them.
let compressed_bytes = self.read_n_bytes(compressed_len)?;
let uncompressed_bytes = miniz_oxide::inflate::decompress_to_vec_zlib_with_limit(
compressed_bytes,
uncompressed_len,
)
.map_err(|e| anyhow!("{e:?}"))?;
ensure!(uncompressed_bytes.len() == uncompressed_len);
Ok(Cow::Owned(uncompressed_bytes))
}
}
}
View on GitHub (pinned to 7088e4b63a)
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.
Example fix
// before: assume any compressed chunk is valid
let bytes = miniz_oxide::inflate::decompress_to_vec_zlib_with_limit(
compressed_bytes, uncompressed_len,
).map_err(|e| anyhow!("{e:?}"))?;
// after: surface a richer, version-aware error
let bytes = miniz_oxide::inflate::decompress_to_vec_zlib_with_limit(
compressed_bytes, uncompressed_len,
).map_err(|e| anyhow!(
"failed to decompress coverage chunk: {e:?} \
(uncompressed_len={uncompressed_len}, compressed_len={compressed_len}); \
the artifact may be from an incompatible LLVM/rustc version"
))? Defensive patterns
Strategy: validation
Validate before calling
// Before invoking coverage-dump on an artifact, sanity-check it is a valid
// coverage file and fully written:
fn looks_like_complete_coverage(path: &Path) -> bool {
let Ok(md) = std::fs::metadata(path) else { return false; };
md.len() > 0 && !path.ends_with(".tmp")
}
// Prefer: only process artifacts produced by the same toolchain in one run. Type guard
null
Try / catch
// Wrap the coverage-dump invocation and report a clear upstream error:
match coverage_dump::dump(&path) {
Ok(out) => { /* ... */ }
Err(e) if e.to_string().contains("decompress") => {
eprintln!("{path:?} appears corrupt or from an incompatible LLVM version: {e}");
std::process::exit(2);
}
Err(e) => return Err(e),
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unexpected base kind for gap region: {kind:?}
- unknown mapping kind: {raw_mapping_kind:#x}
- unparsed bytes: 0x{:02x?}
- llvm-readelf failed for binary {binary} with output {stdout}
- Build ID not found for binary {binary}
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/d9325d1540539ec9.
Report an issue: GitHub.