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

Already on GitHub? Sign in to your account

stack level too deep Ruby 1.9.3-p125 #51

Closed
driki opened this Issue Apr 22, 2012 · 4 comments

Comments

Projects
None yet
4 participants

driki commented Apr 22, 2012

Hi,

I'm encountering a 'stack level too deep' error while trying to work with this PDF file: http://dl.dropbox.com/u/6646130/stack-level-too-deep.pdf

I'm using:

  • OS X Lion 10.7.3
  • ruby 1.9.3-p125
  • gem 'pdf-reader', '1.1.0'
reader = PDF::Reader.new("stack-level-too-deep.pdf")
puts reader.pdf_version
puts reader.info
puts reader.page_count
puts reader.metadata
text   = reader.pages.map{ |page| page.text.strip }.join(' ')

The PDF is:

  • reader.pdf_version: 1.7
  • reader.page_count: 64
$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 2560
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited

I doubled the stack size hoping that might help but it didn't:

$ ulimit -s 16384

Any thoughts on how to resolve this?

Thanks,
Matt

fro commented Jun 11, 2015

Same problem here:

/Users/francois/.rbenv/versions/2.2.0-preview1/gemsets/playground-gems/gems/pdf-reader-1.3.3/lib/pdf/reader/object_cache.rb:71:in `include?': stack level too deep (SystemStackError)
from /Users/francois/.rbenv/versions/2.2.0-preview1/gemsets/playground-gems/gems/pdf-reader-1.3.3/lib/pdf/reader/object_cache.rb:71:in `include?'
from /Users/francois/.rbenv/versions/2.2.0-preview1/gemsets/playground-gems/gems/pdf-reader-1.3.3/lib/pdf/reader/object_hash.rb:79:in `[]'
from /Users/francois/.rbenv/versions/2.2.0-preview1/gemsets/playground-gems/gems/pdf-reader-1.3.3/lib/pdf/reader/object_hash.rb:97:in `object'
from /Users/francois/.rbenv/versions/2.2.0-preview1/gemsets/playground-gems/gems/pdf-reader-1.3.3/lib/pdf/reader/object_hash.rb:105:in `deref!'
from /Users/francois/.rbenv/versions/2.2.0-preview1/gemsets/playground-gems/gems/pdf-reader-1.3.3/lib/pdf/reader/object_hash.rb:109:in `block (2 levels) in deref!'
from /Users/francois/.rbenv/versions/2.2.0-preview1/gemsets/playground-gems/gems/pdf-reader-1.3.3/lib/pdf/reader/object_hash.rb:108:in `each'
from /Users/francois/.rbenv/versions/2.2.0-preview1/gemsets/playground-gems/gems/pdf-reader-1.3.3/lib/pdf/reader/object_hash.rb:108:in `block in deref!'
from /Users/francois/.rbenv/versions/2.2.0-preview1/gemsets/playground-gems/gems/pdf-reader-1.3.3/lib/pdf/reader/object_hash.rb:107:in `tap'
... 9295 levels...
from pdf_customizer.rb:89:in `new'
from pdf_customizer.rb:89:in `block in <main>'
from pdf_customizer.rb:88:in `each'
from pdf_customizer.rb:88:in `<main>'

This problem exists in object_hash.rb:109. The recursive function blows up.

This is the hash that causes it to explode. Any idea @yob

{:Encoding=>:WinAnsiEncoding, :Widths=>[277, 277, 354, 556, 556, 889, 666, 190, 333, 333, 389, 583, 277, 333, 277, 277, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 277, 277, 583, 583, 583, 556, 1015, 666, 666, 722, 722, 666, 610, 777, 722, 277, 500, 666, 556, 833, 722, 777, 666, 777, 722, 666, 610, 722, 666, 943, 666, 666, 610, 277, 277, 277, 469, 556, 333, 556, 556, 500, 556, 556, 277, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 277, 556, 500, 722, 500, 500, 500, 333, 259, 333, 583, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 277, 333, 556, 556, 556, 556, 259, 556, 333, 736, 370, 556, 583, 333, 736, 552, 399, 548, 333, 333, 333, 576, 537, 277, 333, 333, 365, 556, 833, 833, 833, 610, 666, 666, 666, 666, 666, 666, 1000, 722, 666, 666, 666, 666, 277, 277, 277, 277, 722, 722, 777, 777, 777, 777, 777, 583, 777, 722, 722, 722, 722, 666, 666, 610, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 277, 277, 277, 277, 556, 556, 556, 556, 556, 556, 556, 548, 610, 556, 556, 556, 556, 500, 556, 500], :Subtype=>:TrueType, :Type=>:Font, :FirstChar=>32, :LastChar=>255, :FontDescriptor=>#<PDF::Reader::Reference:0x007fe760a02e00 @id=36, @gen=0>, :BaseFont=>:ArialMT}
Owner

yob commented Jan 18, 2017

Thanks for the detailed report, and keeping the sample file in your dropbox for nearly five years!

After some research on #94, I've found the root cause of this issue and confirmed your sample PDF has the same characteristics. I've build a simple pdf and failing spec, so hopefully I can work on a fix soon.

@yob yob closed this Jan 18, 2017

Owner

yob commented Feb 12, 2017

I believe this has been resolved in #198 - please let me know if I'm wrong!

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