Repository navigation
RAR volumes read each byte once: the signature probe is the first piece - #313
Conversation
Opening a RAR volume read its first MiB twice: once to find the signature (up to MAX_SFX + 8 bytes in, for a self-extractor) and again as the reader's first piece. The probe's bytes now seed the reader, so every volume's head is read once, SFX detection unchanged. - The checked route recognizes a RAR from its 1 KiB head when the signature is there, and hands the bytes to the volume; the whole window is probed only for a later signature. - extract::run and list keep the file and head the format sniff read; inspect keeps its probe and handle. - A big stored part copied by position (stored_parallel) takes the bytes the volume read with the headers rather than reading them again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…ad-once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…-volume-head-once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Local CI ( Codex review on |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
…kb and 7z x -so hand over of a failing member (#317) * Opt-in unverified output: UnverifiedOutput::Emit writes, prints and streams what UnRAR and 7-Zip hand over of a failing member - Options::unverified_output (whole-archive RAR runners, RarSession extraction with keep_broken): a RAR member cut off by a missing volume keeps every byte UnRAR 7.30 `x -kb` keeps (RAR 3.x/4.x: LZ tokens starting in the last 30 bytes left out; RAR 5.0: the partial block decoded, symbols in the last 128 bits left out, a block with under 1024 bytes skipped; observed on 50 cut points). - RarPrintOptions::unverified_output (`unrar p`): a member failing on its own data prints what was decoded of it; RarEntryOutcome::unverified_bytes says how many bytes went out. - sevenzip::print_selected_with_options + SevenZipPrintOptions (`7z x -so`): a failing 7z member streams what 7-Zip 26.06 streams (CRC failure: all; data error / cut folder: the bytes before it); Summary::unverified. - SelectOptions::unverified_output (SelectedEntry): 7z as above; RAR 3.x/4.x unsupported VM filters streamed unfiltered; read fails with UnverifiedWritten { bytes, cause }. - LZMA readers hand out the bytes decoded before a data error, then the error. Defaults unchanged. tests/unverified_output.rs checks each route against the reference tools' output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj * Codex on #317: 7z unverified members keep archive order, output errors propagate, LZMA errors at the last byte stay - A member failing behind ones held for the folder's CRC is queued behind them (printed in archive order). - wrong_password() returns a result: an output error replaying held members ends the run. - The LZMA readers put a data error off only when the caller asked for more than was made; one asking for exactly the bytes left never reads again, so the error is returned then (default outcomes unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj * Merge origin/main; unverified_output in the new rar5_link_password literal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj * Codex on #317: cut-member output faults end the run, printing hands over buffered bytes, unfiltered prerequisites don't stop a selected read - Run::emit_unverified returns a fault writing the flushed bytes as the run's terminal error. - RarSession decoding under UnverifiedOutput::Emit flushes what a failing decoder still buffers before the failure (printing and keep_broken extraction get every byte decoded). - SelectedEntry (Emit) goes on past a solid prerequisite written unfiltered; only the selected member's own unfiltered write fails the read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj * Codex on #317: a split part failing its own checksum hands over what was decoded under Emit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj * unverified_output in the Options literal #313 added Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj * unverified_output in the Options literals #316 added Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Why
Prybar's
strace -f -kof a 500 MB, 10-volume RAR5 set showed the first 1 MiB of every volume read twice: once byVolume::open_file→probe_signature(MAX_SFX + 8bytes, even when the signature is at offset 0), and again bySource::fillas the reader's first piece. part01 also paid for the checked route's own 1 MiB + 8 probe. A big stored part copied by position (stored_parallel, ≥ 64 MiB) read that MiB a third time.What
Volumeopening (probe_head) reads the signature window once and seeds the reader's firstSourcepiece with those bytes. If a head was read already (the format sniff's 1 KiB, the checked probe), it is kept, and only what the signature search still needs past it is read. SFX detection is unchanged: the sameSignatureParserover the sameMAX_SFX + 8window.checked_routerecognizes a RAR from its 1 KiB head when the signature is there and hands those bytes to the volume throughHeldSignature. The full-window probe runs only for a later signature (SFX).extract::run/list/list_detailedkeep the file and head thatsniffread (sniff_held).inspectkeeps its probe and handle.stored_parallel:batch::stored_detailedtakes the bytes the volume already holds (Volume::held_at), hashes and writes them first, and reads only the rest.open_catalogue) is unchanged: it reads 8 bytes, and the window only on a mismatch.The catalogue pass and then extraction that Prybar saw on part01 are two separate API calls by the caller, so this PR can't merge them. Each one now reads part01's head once.
Measured (strace -f -ff -y, release build, rustyget-x86-a; stored RAR5 sets made by a generator)
Before, each volume read 1,048,584 extra bytes (2,097,106 with stored_parallel). After, the only repeat is 6 bytes on part01, from the ISO 9660 sniff at 32 KiB.
Tests
A
#[cfg(test)]counter (rar5::reader::VOLUME_READS, fed byread_volume, which both the reader andbatch::stored_detaileduse) records every volume read.assert_read_oncechecks that each volume's reads follow on from each other with no repeats and end at its length.extract::read_once::a_rar5_set_reads_each_volume_once: 3 volumes, with and without a 100 KB SFX prefix, 1 and 4 threadsextract::read_once::the_checked_route_reads_each_volume_once:run_with_policy, with and without an SFX prefixextract::read_once::a_big_stored_part_reads_its_volume_once: thestored_parallelpathextract::read_once::a_rar4_set_reads_each_volume_once: therar4-volumesfixturesextract::read_once::a_rar5_listing_reads_the_first_volume_head_once:listandinspectextract::read_once::a_signature_past_the_window_is_not_found: a stub overMAX_SFXis still not a RAR, and one exactly at the edge is still foundbatch::positional_tests::a_held_head_is_copied_and_only_the_rest_is_readRevert check: with only the counter applied to old main, all five read-once tests fail (
read (0, 1048576) with 1024 read so far,read twice: (0, 1048576) and (0, 1048584)). Localcargo nextest run --workspace --locked: 2930 passed.Clean-room: no third-party code read or used.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj