ICEpdf
  1. ICEpdf
  2. PDF-592

Fatal error parsing PDF file stream. java.util.EmptyStackException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.1
    • Fix Version/s: 5.0.2
    • Component/s: Core/Parsing
    • Labels:
      None
    • Environment:
      Pro, JAI, -Xmx512m
    • Salesforce Case Reference:

      Description

      If memory isn't allocated, the test PDF will run out of java heap memory. I've added 512mb which does seem to help but eventually the sample PDF viewer will crash with the following:

      WARNING: Fatal error parsing PDF file stream.
      java.util.EmptyStackException
      at java.util.Stack.peek(Stack.java:85)
      at java.util.Stack.pop(Stack.java:67)
      at org.icepdf.core.util.Parser.getObject(Parser.java:143)
      at org.icepdf.core.util.LazyObjectLoader.loadObject(LazyObjectLoader.java:73)
      at org.icepdf.core.util.Library.getObject(Library.java:123)
      at org.icepdf.core.pobjects.PageTree.getPageOrPagesPotentiallyNotInitedFromRefe
      renceAt(PageTree.java:238)
      at org.icepdf.core.pobjects.PageTree.getPagePotentiallyNotInitedByRecursiveInde
      x(PageTree.java:257)
      at org.icepdf.core.pobjects.PageTree.getPage(PageTree.java:326)
      at org.icepdf.core.pobjects.Document.getPageText(Document.java:1119)
      at test.IcePdfCrashTest.callPageText(IcePdfCrashTest.java:38)
      at test.IcePdfCrashTest.main(IcePdfCrashTest.java:24)
      java.util.EmptyStackException
      at java.util.Stack.peek(Stack.java:85)
      at java.util.Stack.pop(Stack.java:67)
      at org.icepdf.core.util.Parser.getObject(Parser.java:143)
      at org.icepdf.core.util.LazyObjectLoader.loadObject(LazyObjectLoader.java:73)
      at org.icepdf.core.util.Library.getObject(Library.java:123)
      at org.icepdf.core.pobjects.PageTree.getPageOrPagesPotentiallyNotInitedFromRefe
      renceAt(PageTree.java:238)
      at org.icepdf.core.pobjects.PageTree.getPagePotentiallyNotInitedByRecursiveInde
      x(PageTree.java:257)
      at org.icepdf.core.pobjects.PageTree.getPage(PageTree.java:326)
      at org.icepdf.core.pobjects.Document.getPageText(Document.java:1119)
      at test.IcePdfCrashTest.callPageText(IcePdfCrashTest.java:38)
      at test.IcePdfCrashTest.main(IcePdfCrashTest.java:24)
      May 30, 2013 4:33:55 PM org.icepdf.core.util.Parser getObject

      Is this simply a case of needing more memory? The PDF is 300mb+.

        Activity

        Tyler Johnson created issue -
        Tyler Johnson made changes -
        Field Original Value New Value
        Salesforce Case Reference 5007000000T8BM8AAN
        Patrick Corless made changes -
        Fix Version/s 5.0.2 [ 10972 ]
        Hide
        Patrick Corless added a comment -

        The reason that 5.0 requires more memory to load this PDF is because of a failure when loading the xref table and as a result a linear traversal of the PDF must take place. I've isolated the issue to a number parsing issue in the Parser class. The file in question is quite quite long at 307MB and as result the number that represents the xref is quite large.

        In 5.0 a customer number parsing algorithm was introduced that would return a float. Unfortunately for this file the float is too small and a double needs to be used. I've updated parser to returns doubles for all numbers. Not optimal but easier then putting in a specially case implementation.

        Show
        Patrick Corless added a comment - The reason that 5.0 requires more memory to load this PDF is because of a failure when loading the xref table and as a result a linear traversal of the PDF must take place. I've isolated the issue to a number parsing issue in the Parser class. The file in question is quite quite long at 307MB and as result the number that represents the xref is quite large. In 5.0 a customer number parsing algorithm was introduced that would return a float. Unfortunately for this file the float is too small and a double needs to be used. I've updated parser to returns doubles for all numbers. Not optimal but easier then putting in a specially case implementation.
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #35673 Fri May 31 09:45:04 MDT 2013 patrick.corless PDF-592 fixed an overflow issue when parsing really large numbers.
        Files Changed
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/util/Parser.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #35674 Fri May 31 09:45:32 MDT 2013 patrick.corless PDF-592 fixed an overflow issue when parsing really large numbers.
        Files Changed
        Commit graph MODIFY /icepdf/trunk/icepdf/core/src/org/icepdf/core/util/Parser.java
        Hide
        Patrick Corless added a comment -

        Applied patch to parser to insure overflow doesn't occur when parsing large numbers.

        Show
        Patrick Corless added a comment - Applied patch to parser to insure overflow doesn't occur when parsing large numbers.
        Patrick Corless made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #35677 Fri May 31 11:17:47 MDT 2013 patrick.corless PDF-592 reworked getNumber to keep integers as integers so that precision isn't lost on a cast to (float)
        Files Changed
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/util/Parser.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #35681 Fri May 31 14:40:23 MDT 2013 patrick.corless PDF-592 fixed explicit casting issues from integers to float related to getNumber() parser changes.
        Files Changed
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/annotations/TextMarkupAnnotation.java
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/annotations/LineAnnotation.java
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/graphics/ShadingType2Pattern.java
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/annotations/InkAnnotation.java
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/graphics/ShadingType1Pattern.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #35853 Tue Jun 04 10:34:26 MDT 2013 patrick.corless PDF-592 fixed an overflow issue when parsing really large numbers.
        Files Changed
        Commit graph MODIFY /icepdf/trunk/icepdf/core/src/org/icepdf/core/pobjects/fonts/ofont/Font.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #35865 Tue Jun 04 12:49:49 MDT 2013 patrick.corless PDF-592 fixed explicit casting issues from integers to float related to getNumber() parser changes.
        Files Changed
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/fonts/ofont/Font.java
        Patrick Corless made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Patrick Corless
            Reporter:
            Tyler Johnson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: