Repository navigation
test(reader): add a third-party PDF fixture corpus - #205
Merged
Merged
Conversation
Every reader fixture before this one came from VellumPdf's own writer, which only emits generation 0 and never a hybrid-reference file or another producer's object-stream layout. The #121 review found three defects that trace to exactly that gap, each caught only because a reviewer hand-built the adversarial fixture during review. Sourced from qpdf and poppler where a tool can produce the shape, hand-built where none can. Covers object streams, cross-reference streams, linearization, a genuine incremental update, a nonzero- generation catalog surviving both a read and an appended revision, and three damaged-file shapes. One hybrid fixture pins ISO 32000-2 7.5.8.4's documented convention, confirmed against qpdf and poppler as independent oracles; a related fixture puts the same free-then- redefine shape in a single revision, which the spec does not describe, and is documented as pinning current behavior rather than conformance. Also scopes EncryptedFixtureCorpusTests's embedded-resource coverage scan to the flat-named Encrypted set, now that a second, folder- qualified fixture corpus shares the same test assembly.
Adds the 12th third-party fixture (freed-object-reuse.pdf) and its three behaviour tests, plus fixes for a three-reviewer pass on #205: the EveryEmbeddedFixture_isCoveredByTheTheory guard was an open-ended slash-blocklist that a future folder-qualified corpus could slip past silently, narrowed to name the one known "ThirdParty/" prefix instead. The rest is prose accuracy on a corpus whose bytes and tests were already sound. Wrong citation (pdf-issues#146, a closed Table 19 wording erratum, corrected to the actual open issue on this construct, #237); a VellumPdf source comment misattributed to qpdf; a mismeasured /Length body size (41 bytes, corrected to the qpdf-arbitrated 46); a false qpdf/poppler oracle claim for the hidden-object fixture, where poppler's rendered output shows the page survives but says nothing about the object itself; false causality in the CHANGELOG's qpdf-can't-build-hybrid-files claim; an overclaimed AppendRevision gap that this PR's fixture never calls; and a baseline.pdf fixture never actually opened by a reader test. The corpus's own overall framing gets corrected too: mutation testing found every mutation it could construct also killed a pre-existing synthetic test, so this closes a dialect-confidence gap, not a logic gap in the reader -- and the freed-object-reuse fixture's own test doesn't add discrimination beyond GenerationNumberTests, which the README now says plainly instead of implying otherwise.
The comment above `freed` said PR #193's xref-rebuild fallback would be the natural home for recovering a spuriously-freed object. #193 shipped the /Encrypt-in-XRefStm detection and the endstream hardening; it has no rebuild fallback. Reconstruction is #184, still open. Found while fixing the same defect class in the #196 corpus, where a comment cited a Table 19 wording erratum for a question that erratum does not address. A citation nobody can follow is worse than none — it spends the reader's trust before they reach the part that is right.
Tim81
force-pushed
the
feat/196-third-party-fixtures
branch
from
August 20, 2026 09:16
9313fda to
3003036
Compare
The reuse half of freed-object-reuse.pdf could not fail: revision 3 defines 5 1 obj, so it resolves whether or not revision 2's deletion was recorded. Add object 7, freed in revision 2 and never redefined, where returning null requires having honoured the free entry. Removing freed.UnionWith(localFreed) now fails the test; before, it passed. qpdf discriminates here too, and the revision-2 free list is linked per ISO 32000-2 §7.5.4. Ask for the stale generation before the cache is warm. Resolving 5 1 first cached object 5 at generation 1, so the 5 0 lookup exited on the cached value without reaching the resolution path at all. Five claims were wrong: - The docs said an xref entry's generation must match the object header. Resolve never reads the header's generation when the xref is authoritative; rewriting 5 1 obj's header to 7 leaves the test green. The rule is that the reference's generation must match the entry's. - The note on BrokenStartxref said the test failing once #184 lands would be a success signal. #197 is opt-in and defaults off, so it keeps passing — a failure would be the regression the note told a maintainer to wave through. - qpdf returning null for object 5 was attributed to the deletion. A control with no free entry anywhere gives identical answers; it comes from the merged xref. Object 7 is where qpdf actually discriminates. - The same-section hybrid case was described as unsettled "expert opinion included". Three participants in pdf-issues#237 lean the other way and none supports our reading. Say so, and that we differ deliberately (#206). - One file still credited poppler with resolving the hidden object, retracted elsewhere in the previous pass.
Tim81
force-pushed
the
feat/196-third-party-fixtures
branch
from
August 20, 2026 09:16
3003036 to
6f8de7a
Compare
Tim81
added a commit
that referenced
this pull request
Sep 6, 2026
* test(reader): add a third-party PDF fixture corpus (#196) Every reader fixture before this one came from VellumPdf's own writer, which only emits generation 0 and never a hybrid-reference file or another producer's object-stream layout. The #121 review found three defects that trace to exactly that gap, each caught only because a reviewer hand-built the adversarial fixture during review. Sourced from qpdf and poppler where a tool can produce the shape, hand-built where none can. Covers object streams, cross-reference streams, linearization, a genuine incremental update, a nonzero- generation catalog surviving both a read and an appended revision, and three damaged-file shapes. One hybrid fixture pins ISO 32000-2 7.5.8.4's documented convention, confirmed against qpdf and poppler as independent oracles; a related fixture puts the same free-then- redefine shape in a single revision, which the spec does not describe, and is documented as pinning current behavior rather than conformance. Also scopes EncryptedFixtureCorpusTests's embedded-resource coverage scan to the flat-named Encrypted set, now that a second, folder- qualified fixture corpus shares the same test assembly. * test(reader): add freed-object-reuse fixture, fix #196 review claims Adds the 12th third-party fixture (freed-object-reuse.pdf) and its three behaviour tests, plus fixes for a three-reviewer pass on #205: the EveryEmbeddedFixture_isCoveredByTheTheory guard was an open-ended slash-blocklist that a future folder-qualified corpus could slip past silently, narrowed to name the one known "ThirdParty/" prefix instead. The rest is prose accuracy on a corpus whose bytes and tests were already sound. Wrong citation (pdf-issues#146, a closed Table 19 wording erratum, corrected to the actual open issue on this construct, #237); a VellumPdf source comment misattributed to qpdf; a mismeasured /Length body size (41 bytes, corrected to the qpdf-arbitrated 46); a false qpdf/poppler oracle claim for the hidden-object fixture, where poppler's rendered output shows the page survives but says nothing about the object itself; false causality in the CHANGELOG's qpdf-can't-build-hybrid-files claim; an overclaimed AppendRevision gap that this PR's fixture never calls; and a baseline.pdf fixture never actually opened by a reader test. The corpus's own overall framing gets corrected too: mutation testing found every mutation it could construct also killed a pre-existing synthetic test, so this closes a dialect-confidence gap, not a logic gap in the reader -- and the freed-object-reuse fixture's own test doesn't add discrimination beyond GenerationNumberTests, which the README now says plainly instead of implying otherwise. * docs(reader): point the rebuild-fallback note at the right issue The comment above `freed` said PR #193's xref-rebuild fallback would be the natural home for recovering a spuriously-freed object. #193 shipped the /Encrypt-in-XRefStm detection and the endstream hardening; it has no rebuild fallback. Reconstruction is #184, still open. Found while fixing the same defect class in the #196 corpus, where a comment cited a Table 19 wording erratum for a question that erratum does not address. A citation nobody can follow is worse than none — it spends the reader's trust before they reach the part that is right. * test(reader): make the freed-object deletion load-bearing The reuse half of freed-object-reuse.pdf could not fail: revision 3 defines 5 1 obj, so it resolves whether or not revision 2's deletion was recorded. Add object 7, freed in revision 2 and never redefined, where returning null requires having honoured the free entry. Removing freed.UnionWith(localFreed) now fails the test; before, it passed. qpdf discriminates here too, and the revision-2 free list is linked per ISO 32000-2 §7.5.4. Ask for the stale generation before the cache is warm. Resolving 5 1 first cached object 5 at generation 1, so the 5 0 lookup exited on the cached value without reaching the resolution path at all. Five claims were wrong: - The docs said an xref entry's generation must match the object header. Resolve never reads the header's generation when the xref is authoritative; rewriting 5 1 obj's header to 7 leaves the test green. The rule is that the reference's generation must match the entry's. - The note on BrokenStartxref said the test failing once #184 lands would be a success signal. #197 is opt-in and defaults off, so it keeps passing — a failure would be the regression the note told a maintainer to wave through. - qpdf returning null for object 5 was attributed to the deletion. A control with no free entry anywhere gives identical answers; it comes from the merged xref. Object 7 is where qpdf actually discriminates. - The same-section hybrid case was described as unsettled "expert opinion included". Three participants in pdf-issues#237 lean the other way and none supports our reading. Say so, and that we differ deliberately (#206). - One file still credited poppler with resolving the hidden object, retracted elsewhere in the previous pass.
Tim81
added a commit
that referenced
this pull request
Sep 6, 2026
* test(reader): add a third-party PDF fixture corpus (#196) Every reader fixture before this one came from VellumPdf's own writer, which only emits generation 0 and never a hybrid-reference file or another producer's object-stream layout. The #121 review found three defects that trace to exactly that gap, each caught only because a reviewer hand-built the adversarial fixture during review. Sourced from qpdf and poppler where a tool can produce the shape, hand-built where none can. Covers object streams, cross-reference streams, linearization, a genuine incremental update, a nonzero- generation catalog surviving both a read and an appended revision, and three damaged-file shapes. One hybrid fixture pins ISO 32000-2 7.5.8.4's documented convention, confirmed against qpdf and poppler as independent oracles; a related fixture puts the same free-then- redefine shape in a single revision, which the spec does not describe, and is documented as pinning current behavior rather than conformance. Also scopes EncryptedFixtureCorpusTests's embedded-resource coverage scan to the flat-named Encrypted set, now that a second, folder- qualified fixture corpus shares the same test assembly. * test(reader): add freed-object-reuse fixture, fix #196 review claims Adds the 12th third-party fixture (freed-object-reuse.pdf) and its three behaviour tests, plus fixes for a three-reviewer pass on #205: the EveryEmbeddedFixture_isCoveredByTheTheory guard was an open-ended slash-blocklist that a future folder-qualified corpus could slip past silently, narrowed to name the one known "ThirdParty/" prefix instead. The rest is prose accuracy on a corpus whose bytes and tests were already sound. Wrong citation (pdf-issues#146, a closed Table 19 wording erratum, corrected to the actual open issue on this construct, #237); a VellumPdf source comment misattributed to qpdf; a mismeasured /Length body size (41 bytes, corrected to the qpdf-arbitrated 46); a false qpdf/poppler oracle claim for the hidden-object fixture, where poppler's rendered output shows the page survives but says nothing about the object itself; false causality in the CHANGELOG's qpdf-can't-build-hybrid-files claim; an overclaimed AppendRevision gap that this PR's fixture never calls; and a baseline.pdf fixture never actually opened by a reader test. The corpus's own overall framing gets corrected too: mutation testing found every mutation it could construct also killed a pre-existing synthetic test, so this closes a dialect-confidence gap, not a logic gap in the reader -- and the freed-object-reuse fixture's own test doesn't add discrimination beyond GenerationNumberTests, which the README now says plainly instead of implying otherwise. * docs(reader): point the rebuild-fallback note at the right issue The comment above `freed` said PR #193's xref-rebuild fallback would be the natural home for recovering a spuriously-freed object. #193 shipped the /Encrypt-in-XRefStm detection and the endstream hardening; it has no rebuild fallback. Reconstruction is #184, still open. Found while fixing the same defect class in the #196 corpus, where a comment cited a Table 19 wording erratum for a question that erratum does not address. A citation nobody can follow is worse than none — it spends the reader's trust before they reach the part that is right. * test(reader): make the freed-object deletion load-bearing The reuse half of freed-object-reuse.pdf could not fail: revision 3 defines 5 1 obj, so it resolves whether or not revision 2's deletion was recorded. Add object 7, freed in revision 2 and never redefined, where returning null requires having honoured the free entry. Removing freed.UnionWith(localFreed) now fails the test; before, it passed. qpdf discriminates here too, and the revision-2 free list is linked per ISO 32000-2 §7.5.4. Ask for the stale generation before the cache is warm. Resolving 5 1 first cached object 5 at generation 1, so the 5 0 lookup exited on the cached value without reaching the resolution path at all. Five claims were wrong: - The docs said an xref entry's generation must match the object header. Resolve never reads the header's generation when the xref is authoritative; rewriting 5 1 obj's header to 7 leaves the test green. The rule is that the reference's generation must match the entry's. - The note on BrokenStartxref said the test failing once #184 lands would be a success signal. #197 is opt-in and defaults off, so it keeps passing — a failure would be the regression the note told a maintainer to wave through. - qpdf returning null for object 5 was attributed to the deletion. A control with no free entry anywhere gives identical answers; it comes from the merged xref. Object 7 is where qpdf actually discriminates. - The same-section hybrid case was described as unsettled "expert opinion included". Three participants in pdf-issues#237 lean the other way and none supports our reading. Say so, and that we differ deliberately (#206). - One file still credited poppler with resolving the hidden object, retracted elsewhere in the previous pass.
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.
Closes #196. Test-only: no
src/behaviour change, no public API change.Why
Every PDF in the tree came from VellumPdf's own writer, which only ever emits generation 0, never a
hybrid-reference file, never another producer's object-stream layout. Three defects in the #121 review
shared that root cause, and each was caught only because a reviewer hand-built the adversarial file.
The corpus
Twelve fixtures, each SHA-256-pinned by a guard test and exercised by a behaviour test.
hybrid-spec-convention.pdf/XRefStmhybrid-samesection-undefined.pdffreed-object-reuse.pdf5 1 objacross three revisionsobjstm-xrefstream.pdfqpdf --object-streams=generatelinearized.pdfqpdf --linearize/Linearizedincremental-update.pdfpdfattach%%EOF,/Prev, byte-identical prefixnonzero-gen-base.pdf/nonzero-generation.pdfpdfattachtruncated-tail.pdf,broken-startxref.pdfInvalidDataExceptionlength-mismatch.pdf/Length 64on a 46-byte body; the/Length-preferred branch must verifyendstreamfollows and fall backbaseline.pdfqpdfWhat three reviewers changed
Fixture integrity and test rigour came back sound: all twelve digests correct, every structural property
verified at byte level, every provenance command reproducible, no licensing or clean-room exposure. All
20 behaviour tests die to a targeted reader regression, and a 76,454-variant hostile sweep over the
fixtures produced no exception outside
InvalidDataException/UnsupportedPdfFeatureException.Almost every defect was in what the prose claimed, and the fixes make this PR claim less than it did:
/is a blocklist: afuture
Fixtures/Extra/corpus using the same folder-qualified pattern this PR introduces shippedcompletely uncovered with the suite green. Proven, then narrowed to a
ThirdParty/prefix so any newprefix fails loudly.
pdf-issues#146, a Table 19 wording erratum that never mentions it. The on-point reference is Encryption: PDF MAC integrity protection (ISO/TS 32004) #237, open
and labelled
bug— where the question of which entry wins is explicitly unresolved. The prose nolonger presents the construct as a void the spec left blank, and does not claim anyone has settled it.
PdfObjectParser.cs— our own source.surrounding page survives, and it reads xref streams so it is no stand-in for a PDF 1.4 consumer.
recovered stream length: 46now backs it.LengthMismatch_recoversTheFullStreamBodysurvives a mutation that destroys
ScanToEndstream's tiering, because the fixture holds oneendstream. It pins the/Lengthfallback rule, and now says so.Two honest reframings, both narrowing the claim:
a regression only these files catch — every mutation also killed a pre-existing synthetic test. That
is the stated purpose (confirming the same mechanisms against another producer's dialect), but the PR
should not read as more.
freed-object-reuse.pdfadds an axis, not discrimination. Removing deletion tracking kills twoexisting
GenerationNumberTestsand not the new test: revision 3's definition wins regardless, so thedeletion is never load-bearing. It pins correct end-to-end behaviour on a real three-revision document.
The README says this plainly.
One pre-existing defect fixed in passing
XrefParser.cshas pointed at "PR #193's xref-rebuild fallback" since it was written. #193 shipped the/Encrypt-in-XRefStmdetection and the endstream hardening; reconstruction is #184, still open. Samefailure as the #146 citation above, found by looking for more of them.
Verification
Full solution with
REQUIRE_VERAPDF=1andREQUIRE_BARCODE_ORACLE=1: 4914 passed, 0 failed, 0skipped (Reader.Tests 233 → 272).
dotnet format --verify-no-changesclean,clean-room-check.ps1passes, AOT smoke passes, no tab bytes, no
PublicAPIchange, no released CHANGELOG section altered.