Skip to content

Fix issue #242 - recursion bug#251

Open
romanbsd wants to merge 1 commit intoboazsegev:masterfrom
BioData:master
Open

Fix issue #242 - recursion bug#251
romanbsd wants to merge 1 commit intoboazsegev:masterfrom
BioData:master

Conversation

@romanbsd
Copy link

@romanbsd romanbsd commented Sep 8, 2025

  • In PDF, a page’s /Resources override inherited ones; inheritance only supplies missing entries. So the page dict must win and the parent should only fill gaps. Flipping the merge (child ← parent) with a block that prefers old (the child’s existing values) implements exactly that rule.
  • Using the page dict as the merge target also avoids polluting inheritance_hash (which may be shared across siblings), reducing chances of recursive structure growth that leads to cycles and SystemStackError
  • The merge block is enhanced with early exits for identical objects and identical indirects (and treat reference wrappers as leaves)

Fixes #242

* In PDF, a page’s /Resources override inherited ones; inheritance only supplies missing entries. So the page dict must win and the parent should only fill gaps. Flipping the merge (child ← parent) with a block that prefers old (the child’s existing values) implements exactly that rule.
* Using the page dict as the merge target also avoids polluting inheritance_hash (which may be shared across siblings), reducing chances of recursive structure growth that leads to cycles and SystemStackError
* The merge block is enhanced with early exits for identical objects and identical indirects (and treat reference wrappers as leaves)
@m3thom
Copy link

m3thom commented Sep 29, 2025

I have tried this, and it works. Thank you for the PR. Now I need both this PR and #250. I guess I have to try to find a way around before these PRs are merged and released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WIP]: SystemStackError: stack level too deep when parsing specific PDF files with catalogs[:Resources]

3 participants