Repository navigation
fix(reader): let a same-revision free entry beat the /XRefStm - #372
Merged
Merged
Conversation
Tim81
force-pushed
the
fix/206-xrefstm-same-section
branch
2 times, most recently
from
August 29, 2026 20:20
73fd93f to
f6fcb7a
Compare
Tim81
force-pushed
the
fix/206-xrefstm-same-section
branch
2 times, most recently
from
August 30, 2026 07:57
4aeb762 to
0b97a55
Compare
Given one revision whose classic cross-reference table marks object N free and whose /XRefStm defines it, VellumPdf resolved N from the stream. It now resolves to null, which is what qpdf 12.3.2 does. The reading is defensible rather than compelled. ISO 32000-2 7.5.8.4 has the search proceed to the /XRefStm when an entry is "not found" in a standard section, and never says whether a free entry counts as found -- that inference is ours. The clause also carries a normative sentence requiring a reader to look in the cross-reference stream first, scoped by its own "in the previous section" but pointing the other way read alone; mkl-public raises exactly that in #237 as something needing clarification. What the clause does settle is that its instruction to disregard a free entry applies to one in the PREVIOUS section: the cross-section arrangement its own NOTE and EXAMPLE describe, where this revision's stream defines the object and an earlier one frees it. That case is unchanged. pdf-association/pdf-issues#237 is open and asks precisely this question. Two participants of its four converge on the free entry winning. MatthiasValvekens hedges his -- "I haven't double-checked this, but I believe", and later "maybe my intuition is completely wrong" -- while mkl-public agrees with him unhedged. The other two, petervwyatt and the author, take no position either way. An earlier draft of this message said three converged, which was wrong. Errata #523 is adjacent rather than additional support: its relevant comment is prefixed "Somewhat related" and argues the /XRefStm-before-/Prev half, not the table-before-/XRefStm half this change needs. A second review pass found more. A comment added by the first correction said ISO 32000-2 does not address duplicate object numbers in one table either way; 7.5.4 forbids them outright, in a "shall not". The accurate version is the stronger argument: the clause bans the construct without saying which entry a reader should then take, so taking the first live one is a choice on undefined input rather than a gap. The corpus token added that round pinned the classic table's first subsection header. A later round found it misses a fixture regenerated to append a second subsection, so I replaced it with one pinning where the table ends -- and that was a regression, because the header token was already closing a third route, a subsection PREPENDED before the first. Subsections may appear in any order (7.5.4). A live entry can be smuggled in more than one way -- five constructed so far, not three. The header and table-end tokens each close two of the first three; the other two reuse object 7's real byte offset rather than duplicating its bytes, so pinning that offset directly closes both. All five are pinned now. The executable change is one added line plus one sweep and a recorded flag. This revision's classic-table frees join `freed` before the /XRefStm block, so the stream's own freed.Contains guard can see them; the fold at the end of the method is kept, not moved, since it still carries the /XRefStm's own type-0 entries out to an older /Prev revision. The sweep is DropMembersOfFreedContainers, and the paragraph below says why it exists. A fourth review round found the consequence that matters most, and it is the first that harms an object nobody freed. ParseXrefStream's type-2 guard keys on the member's object number, not its container's, so freeing an /ObjStm container left its compressed members in the merged table pointing at a container that no longer resolved, and reading one threw rather than answering null -- from PdfReader.Open itself, with a different message, when the member was the catalog. qpdf answers null and keeps the file open on the same bytes, so this was the one shape where this reader was harsher than the oracle the change aligns to. Reaching it needs a writer that copies the container's free entry forward without its members': 7.5.8.4's EXAMPLE frees both together, which the member-level guard already handled, so the EXAMPLE is not the shape this fixes. DropMembersOfFreedContainers sweeps the merged table once, after every revision is parsed and `freed` is final, removing a compressed entry whose container is both freed and absent. Both halves of that test carry weight: a container nobody mentions is a different failure and stays one, and `freed` only ever grows, so a stale free from an older revision must not strip members a newer revision made live again. Running once at the end is what makes the ordering safe -- a stream may put a container's type-0 row in a later /Index subsection than its members' type-2 rows, so no check made while a row is added can see the whole picture. Three further consequences are now recorded and pinned: a freed /AcroForm empties the public Signatures list with no exception, so a signed document reads as unsigned; a /XRefStm carrying a row for its own object number shrinks ObjectNumbers and can shrink NextFreeObjectNumber, which Conformance preflight and the signing builders consume; and a hybrid revision in the middle of a /Prev chain loses the object too, which the earlier "cross-section arrangement is unaffected" line read as covering and did not. A fifth round found the sweep's guard keyed on the wrong thing. It asked whether a container number had ever been freed, but object 0 is freed by the free-list head of every classic table, as is anything an incremental update deletes -- so two identically corrupt files got opposite treatment, one swept to null and one thrown on, where qpdf answers null for both. The guard is now absence from the merged table alone. A clean deletion frees the members too and is dropped a layer earlier, so the sweep only ever sees a file that contradicts itself, and there was nothing for the two-part test to distinguish. That also gives the removal a better justification than matching qpdf. 7.3.10 makes an indirect reference to an undefined object legal and null, so dropping a member loses nothing recoverable -- its bytes existed only inside the container -- and a reference to it still means what it meant when the source was read. A copy written from the surviving table agrees with what reading the original returned, which is the property that matters when the answer to a damaged file is a new file rather than a rewrite of the old one. The parser now records that it dropped something, so #184 can refuse to append a revision to such a document alongside the reconstructed ones it already refuses. Two claims here and in the CHANGELOG were false and are corrected. Not everything degrades to null: a freed /Filter or /DecodeParms yields the raw compressed bytes, because an unresolvable /Filter reads as no filter at all. And the shrink in ObjectNumbers reaches outside this package: a PDF/A-2B file whose only violation is a freed external-stream object now validates as compliant where it did not before, because an object that leaves the table leaves the preflight walk with it. PdfPreflight.Validate is Stable API, so that was worth checking against the oracle rather than reasoning about -- and veraPDF 1.30.2 gives the same two verdicts on the same two files, failing the live one on 19005-2 clause 6.1.7.1 test 3 and passing the freed one. Two controls rule out the deflationary readings: an object reachable only through the /XRefStm and not freed still fails, so veraPDF is not ignoring /XRefStm, and a variant breaking a different rule flips the same way on 6.1.7.2. So the flip lands on veraPDF's side of a question the specification leaves open, which is a better place to be than the old answer, subject to the same caveat as everything else here. A final round found nothing wrong with the code and four claims wrong in the prose, three of them written by the corrections before it. The corpus comment said no route to that smuggle could avoid writing object 7's offset; a reviewer built one that duplicates the object's bytes instead, which no token in that row catches. The flag's own doc said #184 already refuses to append to a reconstructed document -- true of its branch, not of main and not of the issue. A list header promised every consequence was measured while two of its bullets said otherwise. And a sentence saying neither shrink had a constructed consequence survived underneath two bullets that construct one. It also found the Conformance test for the sweep did not test the sweep: the missing name-limit Error has two causes and the assertion could not tell them apart, since PreflightContext swallows a resolve failure with catch-continue and reaches the same verdict. It now asserts the members left the table and the flag was set, and fails with the sweep disabled where it passed before. The fixture had to change, and that is where the work went. Its stream was /Index [4 1] -- it defined exactly one object, the same one the classic table frees. After this change the stream contributes nothing, so Assert.Null(Resolve(4)) would have passed whether the free entry correctly won, or the /XRefStm was never followed, or ParseXrefStream threw and was swallowed, or the hybrid path had been deleted outright. It now defines object 7 as well, absent from the classic table, so one test pins both halves: object 4 is null AND object 7's /Note reads SAMESECTIONSTREAM. A review confirmed the test passes for the correct behaviour and fails for each of the other three: the /XRefStm never followed, ParseXrefStream throwing and being swallowed, or the hybrid path deleted outright. The fixture is now emitted by eng/generate-hybrid-samesection-fixture.py, which derives every offset from the bytes it just wrote. Four of the five hand-built fixtures still have no generator; the README recorded their provenance rather than a reproduction recipe, and now records a command for this one. Three tests are added for mechanisms nothing pinned. Deleting the trailing fold, or collapsing the per-parse free set into the shared one, previously left the whole suite green while changing what documents resolve to. The isolation tests also record that qpdf answers null where we take the first non-free entry, a divergence on malformed input we accept deliberately. Both pinned behaviour tests are rewritten rather than inverted. Object 4 is the page's /Contents, so the page now has no content stream at all -- an absence, not a fallback -- and the test says so. A synthetic test in XrefStreamTests pinned the old behaviour too; it is inverted, and its builder gained a second object so it no longer has the vacuity this commit removed from the fixture. Closes #206
Tim81
force-pushed
the
fix/206-xrefstm-same-section
branch
from
August 30, 2026 08:38
0b97a55 to
6a222c4
Compare
This was referenced Aug 30, 2026
Tim81
added a commit
that referenced
this pull request
Sep 6, 2026
Given one revision whose classic cross-reference table marks object N free and whose /XRefStm defines it, VellumPdf resolved N from the stream. It now resolves to null, which is what qpdf 12.3.2 does. The reading is defensible rather than compelled. ISO 32000-2 7.5.8.4 has the search proceed to the /XRefStm when an entry is "not found" in a standard section, and never says whether a free entry counts as found -- that inference is ours. The clause also carries a normative sentence requiring a reader to look in the cross-reference stream first, scoped by its own "in the previous section" but pointing the other way read alone; mkl-public raises exactly that in #237 as something needing clarification. What the clause does settle is that its instruction to disregard a free entry applies to one in the PREVIOUS section: the cross-section arrangement its own NOTE and EXAMPLE describe, where this revision's stream defines the object and an earlier one frees it. That case is unchanged. pdf-association/pdf-issues#237 is open and asks precisely this question. Two participants of its four converge on the free entry winning. MatthiasValvekens hedges his -- "I haven't double-checked this, but I believe", and later "maybe my intuition is completely wrong" -- while mkl-public agrees with him unhedged. The other two, petervwyatt and the author, take no position either way. An earlier draft of this message said three converged, which was wrong. Errata #523 is adjacent rather than additional support: its relevant comment is prefixed "Somewhat related" and argues the /XRefStm-before-/Prev half, not the table-before-/XRefStm half this change needs. A second review pass found more. A comment added by the first correction said ISO 32000-2 does not address duplicate object numbers in one table either way; 7.5.4 forbids them outright, in a "shall not". The accurate version is the stronger argument: the clause bans the construct without saying which entry a reader should then take, so taking the first live one is a choice on undefined input rather than a gap. The corpus token added that round pinned the classic table's first subsection header. A later round found it misses a fixture regenerated to append a second subsection, so I replaced it with one pinning where the table ends -- and that was a regression, because the header token was already closing a third route, a subsection PREPENDED before the first. Subsections may appear in any order (7.5.4). A live entry can be smuggled in more than one way -- five constructed so far, not three. The header and table-end tokens each close two of the first three; the other two reuse object 7's real byte offset rather than duplicating its bytes, so pinning that offset directly closes both. All five are pinned now. The executable change is one added line plus one sweep and a recorded flag. This revision's classic-table frees join `freed` before the /XRefStm block, so the stream's own freed.Contains guard can see them; the fold at the end of the method is kept, not moved, since it still carries the /XRefStm's own type-0 entries out to an older /Prev revision. The sweep is DropMembersOfFreedContainers, and the paragraph below says why it exists. A fourth review round found the consequence that matters most, and it is the first that harms an object nobody freed. ParseXrefStream's type-2 guard keys on the member's object number, not its container's, so freeing an /ObjStm container left its compressed members in the merged table pointing at a container that no longer resolved, and reading one threw rather than answering null -- from PdfReader.Open itself, with a different message, when the member was the catalog. qpdf answers null and keeps the file open on the same bytes, so this was the one shape where this reader was harsher than the oracle the change aligns to. Reaching it needs a writer that copies the container's free entry forward without its members': 7.5.8.4's EXAMPLE frees both together, which the member-level guard already handled, so the EXAMPLE is not the shape this fixes. DropMembersOfFreedContainers sweeps the merged table once, after every revision is parsed and `freed` is final, removing a compressed entry whose container is both freed and absent. Both halves of that test carry weight: a container nobody mentions is a different failure and stays one, and `freed` only ever grows, so a stale free from an older revision must not strip members a newer revision made live again. Running once at the end is what makes the ordering safe -- a stream may put a container's type-0 row in a later /Index subsection than its members' type-2 rows, so no check made while a row is added can see the whole picture. Three further consequences are now recorded and pinned: a freed /AcroForm empties the public Signatures list with no exception, so a signed document reads as unsigned; a /XRefStm carrying a row for its own object number shrinks ObjectNumbers and can shrink NextFreeObjectNumber, which Conformance preflight and the signing builders consume; and a hybrid revision in the middle of a /Prev chain loses the object too, which the earlier "cross-section arrangement is unaffected" line read as covering and did not. A fifth round found the sweep's guard keyed on the wrong thing. It asked whether a container number had ever been freed, but object 0 is freed by the free-list head of every classic table, as is anything an incremental update deletes -- so two identically corrupt files got opposite treatment, one swept to null and one thrown on, where qpdf answers null for both. The guard is now absence from the merged table alone. A clean deletion frees the members too and is dropped a layer earlier, so the sweep only ever sees a file that contradicts itself, and there was nothing for the two-part test to distinguish. That also gives the removal a better justification than matching qpdf. 7.3.10 makes an indirect reference to an undefined object legal and null, so dropping a member loses nothing recoverable -- its bytes existed only inside the container -- and a reference to it still means what it meant when the source was read. A copy written from the surviving table agrees with what reading the original returned, which is the property that matters when the answer to a damaged file is a new file rather than a rewrite of the old one. The parser now records that it dropped something, so #184 can refuse to append a revision to such a document alongside the reconstructed ones it already refuses. Two claims here and in the CHANGELOG were false and are corrected. Not everything degrades to null: a freed /Filter or /DecodeParms yields the raw compressed bytes, because an unresolvable /Filter reads as no filter at all. And the shrink in ObjectNumbers reaches outside this package: a PDF/A-2B file whose only violation is a freed external-stream object now validates as compliant where it did not before, because an object that leaves the table leaves the preflight walk with it. PdfPreflight.Validate is Stable API, so that was worth checking against the oracle rather than reasoning about -- and veraPDF 1.30.2 gives the same two verdicts on the same two files, failing the live one on 19005-2 clause 6.1.7.1 test 3 and passing the freed one. Two controls rule out the deflationary readings: an object reachable only through the /XRefStm and not freed still fails, so veraPDF is not ignoring /XRefStm, and a variant breaking a different rule flips the same way on 6.1.7.2. So the flip lands on veraPDF's side of a question the specification leaves open, which is a better place to be than the old answer, subject to the same caveat as everything else here. A final round found nothing wrong with the code and four claims wrong in the prose, three of them written by the corrections before it. The corpus comment said no route to that smuggle could avoid writing object 7's offset; a reviewer built one that duplicates the object's bytes instead, which no token in that row catches. The flag's own doc said #184 already refuses to append to a reconstructed document -- true of its branch, not of main and not of the issue. A list header promised every consequence was measured while two of its bullets said otherwise. And a sentence saying neither shrink had a constructed consequence survived underneath two bullets that construct one. It also found the Conformance test for the sweep did not test the sweep: the missing name-limit Error has two causes and the assertion could not tell them apart, since PreflightContext swallows a resolve failure with catch-continue and reaches the same verdict. It now asserts the members left the table and the flag was set, and fails with the sweep disabled where it passed before. The fixture had to change, and that is where the work went. Its stream was /Index [4 1] -- it defined exactly one object, the same one the classic table frees. After this change the stream contributes nothing, so Assert.Null(Resolve(4)) would have passed whether the free entry correctly won, or the /XRefStm was never followed, or ParseXrefStream threw and was swallowed, or the hybrid path had been deleted outright. It now defines object 7 as well, absent from the classic table, so one test pins both halves: object 4 is null AND object 7's /Note reads SAMESECTIONSTREAM. A review confirmed the test passes for the correct behaviour and fails for each of the other three: the /XRefStm never followed, ParseXrefStream throwing and being swallowed, or the hybrid path deleted outright. The fixture is now emitted by eng/generate-hybrid-samesection-fixture.py, which derives every offset from the bytes it just wrote. Four of the five hand-built fixtures still have no generator; the README recorded their provenance rather than a reproduction recipe, and now records a command for this one. Three tests are added for mechanisms nothing pinned. Deleting the trailing fold, or collapsing the per-parse free set into the shared one, previously left the whole suite green while changing what documents resolve to. The isolation tests also record that qpdf answers null where we take the first non-free entry, a divergence on malformed input we accept deliberately. Both pinned behaviour tests are rewritten rather than inverted. Object 4 is the page's /Contents, so the page now has no content stream at all -- an absence, not a fallback -- and the test says so. A synthetic test in XrefStreamTests pinned the old behaviour too; it is inverted, and its builder gained a second object so it no longer has the vacuity this commit removed from the fixture. Closes #206
Tim81
added a commit
that referenced
this pull request
Sep 6, 2026
Given one revision whose classic cross-reference table marks object N free and whose /XRefStm defines it, VellumPdf resolved N from the stream. It now resolves to null, which is what qpdf 12.3.2 does. The reading is defensible rather than compelled. ISO 32000-2 7.5.8.4 has the search proceed to the /XRefStm when an entry is "not found" in a standard section, and never says whether a free entry counts as found -- that inference is ours. The clause also carries a normative sentence requiring a reader to look in the cross-reference stream first, scoped by its own "in the previous section" but pointing the other way read alone; mkl-public raises exactly that in #237 as something needing clarification. What the clause does settle is that its instruction to disregard a free entry applies to one in the PREVIOUS section: the cross-section arrangement its own NOTE and EXAMPLE describe, where this revision's stream defines the object and an earlier one frees it. That case is unchanged. pdf-association/pdf-issues#237 is open and asks precisely this question. Two participants of its four converge on the free entry winning. MatthiasValvekens hedges his -- "I haven't double-checked this, but I believe", and later "maybe my intuition is completely wrong" -- while mkl-public agrees with him unhedged. The other two, petervwyatt and the author, take no position either way. An earlier draft of this message said three converged, which was wrong. Errata #523 is adjacent rather than additional support: its relevant comment is prefixed "Somewhat related" and argues the /XRefStm-before-/Prev half, not the table-before-/XRefStm half this change needs. A second review pass found more. A comment added by the first correction said ISO 32000-2 does not address duplicate object numbers in one table either way; 7.5.4 forbids them outright, in a "shall not". The accurate version is the stronger argument: the clause bans the construct without saying which entry a reader should then take, so taking the first live one is a choice on undefined input rather than a gap. The corpus token added that round pinned the classic table's first subsection header. A later round found it misses a fixture regenerated to append a second subsection, so I replaced it with one pinning where the table ends -- and that was a regression, because the header token was already closing a third route, a subsection PREPENDED before the first. Subsections may appear in any order (7.5.4). A live entry can be smuggled in more than one way -- five constructed so far, not three. The header and table-end tokens each close two of the first three; the other two reuse object 7's real byte offset rather than duplicating its bytes, so pinning that offset directly closes both. All five are pinned now. The executable change is one added line plus one sweep and a recorded flag. This revision's classic-table frees join `freed` before the /XRefStm block, so the stream's own freed.Contains guard can see them; the fold at the end of the method is kept, not moved, since it still carries the /XRefStm's own type-0 entries out to an older /Prev revision. The sweep is DropMembersOfFreedContainers, and the paragraph below says why it exists. A fourth review round found the consequence that matters most, and it is the first that harms an object nobody freed. ParseXrefStream's type-2 guard keys on the member's object number, not its container's, so freeing an /ObjStm container left its compressed members in the merged table pointing at a container that no longer resolved, and reading one threw rather than answering null -- from PdfReader.Open itself, with a different message, when the member was the catalog. qpdf answers null and keeps the file open on the same bytes, so this was the one shape where this reader was harsher than the oracle the change aligns to. Reaching it needs a writer that copies the container's free entry forward without its members': 7.5.8.4's EXAMPLE frees both together, which the member-level guard already handled, so the EXAMPLE is not the shape this fixes. DropMembersOfFreedContainers sweeps the merged table once, after every revision is parsed and `freed` is final, removing a compressed entry whose container is both freed and absent. Both halves of that test carry weight: a container nobody mentions is a different failure and stays one, and `freed` only ever grows, so a stale free from an older revision must not strip members a newer revision made live again. Running once at the end is what makes the ordering safe -- a stream may put a container's type-0 row in a later /Index subsection than its members' type-2 rows, so no check made while a row is added can see the whole picture. Three further consequences are now recorded and pinned: a freed /AcroForm empties the public Signatures list with no exception, so a signed document reads as unsigned; a /XRefStm carrying a row for its own object number shrinks ObjectNumbers and can shrink NextFreeObjectNumber, which Conformance preflight and the signing builders consume; and a hybrid revision in the middle of a /Prev chain loses the object too, which the earlier "cross-section arrangement is unaffected" line read as covering and did not. A fifth round found the sweep's guard keyed on the wrong thing. It asked whether a container number had ever been freed, but object 0 is freed by the free-list head of every classic table, as is anything an incremental update deletes -- so two identically corrupt files got opposite treatment, one swept to null and one thrown on, where qpdf answers null for both. The guard is now absence from the merged table alone. A clean deletion frees the members too and is dropped a layer earlier, so the sweep only ever sees a file that contradicts itself, and there was nothing for the two-part test to distinguish. That also gives the removal a better justification than matching qpdf. 7.3.10 makes an indirect reference to an undefined object legal and null, so dropping a member loses nothing recoverable -- its bytes existed only inside the container -- and a reference to it still means what it meant when the source was read. A copy written from the surviving table agrees with what reading the original returned, which is the property that matters when the answer to a damaged file is a new file rather than a rewrite of the old one. The parser now records that it dropped something, so #184 can refuse to append a revision to such a document alongside the reconstructed ones it already refuses. Two claims here and in the CHANGELOG were false and are corrected. Not everything degrades to null: a freed /Filter or /DecodeParms yields the raw compressed bytes, because an unresolvable /Filter reads as no filter at all. And the shrink in ObjectNumbers reaches outside this package: a PDF/A-2B file whose only violation is a freed external-stream object now validates as compliant where it did not before, because an object that leaves the table leaves the preflight walk with it. PdfPreflight.Validate is Stable API, so that was worth checking against the oracle rather than reasoning about -- and veraPDF 1.30.2 gives the same two verdicts on the same two files, failing the live one on 19005-2 clause 6.1.7.1 test 3 and passing the freed one. Two controls rule out the deflationary readings: an object reachable only through the /XRefStm and not freed still fails, so veraPDF is not ignoring /XRefStm, and a variant breaking a different rule flips the same way on 6.1.7.2. So the flip lands on veraPDF's side of a question the specification leaves open, which is a better place to be than the old answer, subject to the same caveat as everything else here. A final round found nothing wrong with the code and four claims wrong in the prose, three of them written by the corrections before it. The corpus comment said no route to that smuggle could avoid writing object 7's offset; a reviewer built one that duplicates the object's bytes instead, which no token in that row catches. The flag's own doc said #184 already refuses to append to a reconstructed document -- true of its branch, not of main and not of the issue. A list header promised every consequence was measured while two of its bullets said otherwise. And a sentence saying neither shrink had a constructed consequence survived underneath two bullets that construct one. It also found the Conformance test for the sweep did not test the sweep: the missing name-limit Error has two causes and the assertion could not tell them apart, since PreflightContext swallows a resolve failure with catch-continue and reaches the same verdict. It now asserts the members left the table and the flag was set, and fails with the sweep disabled where it passed before. The fixture had to change, and that is where the work went. Its stream was /Index [4 1] -- it defined exactly one object, the same one the classic table frees. After this change the stream contributes nothing, so Assert.Null(Resolve(4)) would have passed whether the free entry correctly won, or the /XRefStm was never followed, or ParseXrefStream threw and was swallowed, or the hybrid path had been deleted outright. It now defines object 7 as well, absent from the classic table, so one test pins both halves: object 4 is null AND object 7's /Note reads SAMESECTIONSTREAM. A review confirmed the test passes for the correct behaviour and fails for each of the other three: the /XRefStm never followed, ParseXrefStream throwing and being swallowed, or the hybrid path deleted outright. The fixture is now emitted by eng/generate-hybrid-samesection-fixture.py, which derives every offset from the bytes it just wrote. Four of the five hand-built fixtures still have no generator; the README recorded their provenance rather than a reproduction recipe, and now records a command for this one. Three tests are added for mechanisms nothing pinned. Deleting the trailing fold, or collapsing the per-parse free set into the shared one, previously left the whole suite green while changing what documents resolve to. The isolation tests also record that qpdf answers null where we take the first non-free entry, a divergence on malformed input we accept deliberately. Both pinned behaviour tests are rewritten rather than inverted. Object 4 is the page's /Contents, so the page now has no content stream at all -- an absence, not a fallback -- and the test says so. A synthetic test in XrefStreamTests pinned the old behaviour too; it is inverted, and its builder gained a second object so it no longer has the vacuity this commit removed from the fixture. Closes #206
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.
Given one revision whose classic cross-reference table marks object N free and
whose /XRefStm defines it, VellumPdf resolved N from the stream. It now resolves
to null, which is what qpdf 12.3.2 does.
The reading is defensible rather than compelled. ISO 32000-2 7.5.8.4 has the
search proceed to the /XRefStm when an entry is "not found" in a standard
section, and never says whether a free entry counts as found -- that inference is
ours. The clause also carries a normative sentence requiring a reader to look in
the cross-reference stream first, scoped by its own "in the previous section" but
pointing the other way read alone; mkl-public raises exactly that in #237 as
something needing clarification. What the clause does settle is that its
instruction to disregard a free entry applies to one in the PREVIOUS section: the
cross-section arrangement its own NOTE and EXAMPLE describe, where this revision's
stream defines the object and an earlier one frees it. That case is unchanged.
pdf-association/pdf-issues#237 is open and asks precisely this question. Two
participants converge on the free entry winning, qualifiedly -- MatthiasValvekens
opens "I haven't double-checked this, but I believe" and closes "maybe my
intuition is completely wrong", and mkl-public agrees with him. A third takes no
position either way. An earlier draft of this message said three converged, which
was wrong. Errata #523 is adjacent rather than additional support: its relevant
comment is prefixed "Somewhat related" and argues the /XRefStm-before-/Prev half,
not the table-before-/XRefStm half this change needs.
The executable change is one added line: this revision's classic-table frees join
freedbefore the /XRefStm block, so the stream's own freed.Contains guard cansee them. The fold at the end of the method is kept, not moved -- it still
carries the /XRefStm's own type-0 entries out to an older /Prev revision.
The fixture had to change, and that is where the work went. Its stream was
/Index [4 1] -- it defined exactly one object, the same one the classic table
frees. After this change the stream contributes nothing, so Assert.Null(Resolve(4))
would have passed whether the free entry correctly won, or the /XRefStm was never
followed, or ParseXrefStream threw and was swallowed, or the hybrid path had been
deleted outright. It now defines object 7 as well, absent from the classic table,
so one test pins both halves: object 4 is null AND object 7's /Note reads
SAMESECTIONSTREAM. A review confirmed each of those four failures now fails the
test, naming the right half. The corpus row also pins the classic subsection
header, without which a fixture regenerated with object 7 live passed every guard
with the hybrid path disabled.
The fixture is now emitted by eng/generate-hybrid-samesection-fixture.py, which
derives every offset from the bytes it just wrote. Four of the five hand-built
fixtures still have no generator; the README recorded their provenance rather
than a reproduction recipe, and now records a command for this one.
Three tests are added for mechanisms nothing pinned. Deleting the trailing fold,
or collapsing the per-parse free set into the shared one, previously left the
whole suite green while changing what documents resolve to. The isolation tests
also record that qpdf answers null where we take the first non-free entry, a
divergence on malformed input we accept deliberately.
Both pinned behaviour tests are rewritten rather than inverted. Object 4 is the
page's /Contents, so the page now has no content stream at all -- an absence, not
a fallback -- and the test says so. A synthetic test in XrefStreamTests pinned
the old behaviour too; it is inverted, and its builder gained a second object so
it no longer has the vacuity this commit removed from the fixture.
Closes #206