Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getText() -> Maximum function nesting level of '100' reached, aborting! #20

Closed
Garrcomm opened this issue Feb 17, 2014 · 10 comments · Fixed by #55
Closed

getText() -> Maximum function nesting level of '100' reached, aborting! #20

Garrcomm opened this issue Feb 17, 2014 · 10 comments · Fixed by #55

Comments

@Garrcomm
Copy link

Hi,

Today I received feedback about a failing PDF. It generated a function nesting error.
I wrote a small patch that masked the problem, which is kinda dirty.

I can only upload images to a ticket, so I uploaded the files somewhere else:
The error call stack: http://nederland.ligtin.eu/sthoolen/20140217-pdfparser-error.html
The dirty patch: http://nederland.ligtin.eu/sthoolen/20140217-pdfparser-quickfix.patch
The PDF: http://www.vgogh.nl/documenten/huwelijkse_voorwaarden/files/assets/downloads/publication.pdf

Hopefully this problem can be dealt with in a somewhat more decent way? ;-)

@DanielRuf
Copy link

related to #28

@Garrcomm
Copy link
Author

I already thought both issues were related. The problem is not an infinite loop though, it's not infinite. But still nested too deep.
A PDF can have a text container in another container. Some PDFs have nested text containers too deeply. For each nest, the method calls itself.

@DanielRuf
Copy link

Right. I had fixed this issue by increasing the memory for the script. So there are 2 options if I understand it: either PdfParser goes as deep as possible and extracts all texts or we go not so deep and can not extract all texts. The Page object contains everything and this object is parsed in each run of the loop.

My PHP installation gave me a warning about using too much memory (allowed memory size of ... exhausted ...) which was partly solved by increasing/setting a higher memory limit for the script.

Is this the right line? https://github.com/smalot/pdfparser/blob/master/src/Smalot/PdfParser/Object.php#L136

I would say it is not a bug but a problem with special PDF versions and the nesting of contents and especially with XDebug (it seems you are using xdebug and this is a known problem/bug in XDebug).

Also, please take a look at:
http://stackoverflow.com/questions/8656089/solution-for-fatal-error-maximum-function-nesting-level-of-100-reached-abor

and

http://stackoverflow.com/questions/4293775/increasing-nesting-functions-calls-limit

and

http://stackoverflow.com/questions/10157649/maximum-function-nesting-level-of-100-reached-aborting

I do not get your error but just warns about the memory limit. I do not use XDebug.

@DanielRuf
Copy link

@smalot I think we should flatten the whole structure a bit, so we have less recursive function calls. One solution would be an array: http://stackoverflow.com/a/8656421/753676

Another solution is SplQueue (maybe much faster and better but needs at least PHP 5.3) http://www.php.net/manual/en/class.splqueue.php

@smalot
Copy link
Owner

smalot commented Mar 23, 2014

Currently PHP 5.3 is already a requirement due to namespace use.

Envoyé avec AquaMail pour Android
http://www.aqua-mail.com

Le 22 mars 2014 15:34:52 Daniel Ruf notifications@github.com a écrit :

@smalot I think we should flatten the whole structure a bit, so we have
less recursive function calls. One solution would be an array:
http://stackoverflow.com/a/8656421/753676

Another solution is SplQueue (maybe much faster and better but needs at
least PHP 5.3) http://www.php.net/manual/en/class.splqueue.php


Reply to this email directly or view it on GitHub:
#20 (comment)

@DanielRuf
Copy link

Right, but we need to change the structure and use a queue.

@aik099
Copy link
Contributor

aik099 commented Jan 15, 2015

I'm having small document (4 pages) and still getting this issue due an infinite recursion where text of an object with Fm0 contains reference to same object: Do Fm0 and it never ends.

PDF: https://www.dropbox.com/s/ks78qbatmik1d2k/nesting_level_issue.pdf?dl=0

Issues happens with top text on last page.

@aik099
Copy link
Contributor

aik099 commented Jan 15, 2015

The mentioned recursion was introduced in 51f7951 commit where support for nested xObjects were introduced.

@smalot
Copy link
Owner

smalot commented Jan 15, 2015

Hi Alexander,

Currently I'm quite busy, so if you find a fix, I'm ok to test it and
release it.

Thanks

Sébastien MALOT

Please consider the environment before printing this email.

2015-01-15 15:33 GMT+01:00 Alexander Obuhovich notifications@github.com:

The mentioned recursion was introduced in 51f7951
51f7951
commit where support for nested xObjects were introduced.


Reply to this email directly or view it on GitHub
#20 (comment).

@aik099
Copy link
Contributor

aik099 commented Jan 15, 2015

I've created a fix in #55 . Everybody interested please test on your PDFs if that does solve nesting level problem (for users with xdebug installed) / out of memory problem (for users without xdebug installed).

GreyWyvern added a commit to GreyWyvern/pdfparser that referenced this issue Jul 6, 2023
Add ability for PdfParser to parse metadata names with hexadecimal encoded characters such as "Document#20Type" where \smalot#20 is a space.
Resolves Issue smalot#529
k00ni added a commit that referenced this issue Jul 11, 2023
* Update Element.php

Add ability for PdfParser to parse metadata names with hexadecimal encoded characters such as "Document#20Type" where \#20 is a space.
Resolves Issue #529

* Update ElementTest.php

Add test for spaces in metadata property names.

* Make sure we fully support hex

Too quick on the commit! Make sure our two 'digit' regexp also finds A-F hex digits. Add a test for #2d which is a hyphen.

* fixed coding style issue in Element.php

---------

Co-authored-by: Konrad Abicht <hi@inspirito.de>
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 a pull request may close this issue.

4 participants