You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (Jira)" <ji...@apache.org> on 2026/10/18 09:58:00 UTC

[jira] [Commented] (PDFBOX-6286) PDPageTree.get reports false recursion after an out-of-range lookup

    [ https://issues.apache.org/jira/browse/PDFBOX-6286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18128386#comment-18128386 ] 

Tilman Hausherr commented on PDFBOX-6286:
-----------------------------------------

I'd prefer to just clear the page set before throwing an exception.

> PDPageTree.get reports false recursion after an out-of-range lookup
> -------------------------------------------------------------------
>
>                 Key: PDFBOX-6286
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6286
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Aryan Ganjoo
>            Priority: Minor
>
> h3. Observed
> On current PDFBox trunk {{e314c402afd4cac4d60d6d16dbe6525d83637ba8}}, an out-of-range {{PDPageTree.get(1)}} on a one-page document throws as expected, but a subsequent valid {{get(0)}} on the *same* tree throws {{IllegalStateException: Possible recursion found when searching for page 1}}. The document is generated in memory and contains no page-tree cycle.
> h3. Minimal reproduction
> {code:java}
> try (PDDocument document = new PDDocument()) {
>     PDPage page = new PDPage();
>     document.addPage(page);
>     PDPageTree pages = document.getPages();
>     try { pages.get(1); } catch (IndexOutOfBoundsException expected) { }
>     pages.get(0); // unexpectedly reports recursion
> }
> {code}
> h3. Cause and expected behavior
> The lookup keeps visited page dictionaries in an instance field. The failed lookup adds the root and exits without clearing that field, so the next lookup sees stale state. A fresh lookup should be able to retrieve page zero; cycle detection should remain scoped to one traversal. This is separate from PDFBOX-3349 (the out-of-range request itself) and PDFBOX-5278 (an annotation/type mutation on a particular PDF).
> h3. Local validation and limits
> A regression failed on unmodified trunk and passed with a local candidate that uses a per-lookup visited set. The affected {{TestPDPageTree}} class passed 8 tests, zero failures/errors. The full suite, stable branches, nested-cycle cases, and downstream use were not tested. No private PDF or application data was used. This is an issue report, not a submitted patch. AI assistance was used for discovery, test and patch preparation, and local validation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org