Repository navigation
Conversation
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
sokra
added this pull request to stack #100317
October 16, 2026 16:23
Contributor
Tests PassedCommit: 93829f1 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #100316.
The 8-byte headers of SST blocks and blob files store
[uncompressed_length][crc32], but the CRC only covered the payload. A corrupted length therefore passed the checksum check and could:0means uncompressed).The CRC now covers the four big-endian length bytes followed by the on-disk payload.
checksum_block(uncompressed_length, data)hashes both incrementally withcrc32fast::Hasher, so no extra copy is made.Readers verify this checksum before using the length to allocate decompression output or to choose the decompression path. This applies to the mmap and file SST readers (lookups, decoded iteration and the index block), to blob reads and to
sst_inspect.The index block's checksum is now verified before its sentinel check, so a corrupted index length is reported as a checksum error.
The on-disk layout is unchanged, but the meaning of the checksum changes. Caches written by older builds fail validation and are treated as cache corruption.
Iteration still passes medium value blocks to compaction as raw bytes without decompressing them. Their original length and CRC are preserved through the copy, so a corrupted block is detected when the copied value is read. The README documents the new checksum coverage for SST blocks and blob files.
Not covered: a CRC detects accidental corruption, not tampering. There is no cap on the output size, and no compatibility reader for old caches.
Verification
Tests that corrupt only the length header, with offsets left valid:
sst_inspect.Commands run:
cargo test -p turbo-persistence --all-targetscargo test -p turbo-persistence --features strict_checkscargo test -p turbo-persistence --no-default-featurescargo clippy -p turbo-persistence --all-targets, run with the default features, with--no-default-featuresand with--features strict_checkscargo check -p turbo-tasks-backendBefore this change, small length corruptions in blob files were caught only by the decompressor, not by the checksum check.