ICEpdf
  1. ICEpdf
  2. PDF-1300

ICEpdf fails to terminate when rendering a page

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 5.1.1, 6.2.2, 6.3.2
    • Fix Version/s: 6.3.3
    • Component/s: Core/Parsing
    • Labels:
      None
    • Environment:
      Linux

      Description

      As explained in my comment in the forum thread, some PDF files make icepdf enter an infinite loop when looking for the content of an inline image.

      {code}
      stackTrace:
      java.lang.Thread.State: RUNNABLE
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
      - locked <0x0000000607eeed68> (a org.icepdf.core.io.BufferedMarkedInputStream)
      at org.icepdf.core.io.BufferedMarkedInputStream.read(BufferedMarkedInputStream.java:50)
      at org.icepdf.core.util.Parser.peek2(Parser.java:532)
      at org.icepdf.core.util.content.OContentParser.parseInlineImage(OContentParser.java:1104)
      at org.icepdf.core.util.content.OContentParser.parse(OContentParser.java:550)
      at org.icepdf.core.pobjects.Page.init(Page.java:399)
      - locked <0x0000000607db6e18> (a org.icepdf.core.pobjects.Page)
      at org.icepdf.core.pobjects.Document.getPageImage(Document.java:1142)
      {code}

      I reproduced this with the 2 PDF files from the forum link and some test code that does

      {code}
      Document document = new Document();
      document.setByteArray(pdf, 0, pdf.length, null);

      if (document.getNumberOfPages() <= 0) {
              throw new IllegalArgumentException("No page!");
      }

      BufferedImage image = (BufferedImage) document.getPageImage(0,
                          GraphicsRenderingHints.SCREEN, Page.BOUNDARY_CROPBOX, 0f, 1.0f);
      ImageIO.write(image, "jpg", baos);
      return baos.toByteArray();
      {code}

        Activity

        Hide
        Arnaud Jeansen added a comment -

        This patch makes icepdf exit the loop to look for the end of the inline image.
        In my limited testing (two problematic files + 1 control file), this fixes the infinite loop and doesn't regress the control file.

        I am in the process of signing the CLA...

        Show
        Arnaud Jeansen added a comment - This patch makes icepdf exit the loop to look for the end of the inline image. In my limited testing (two problematic files + 1 control file), this fixes the infinite loop and doesn't regress the control file. I am in the process of signing the CLA...
        Hide
        Arnaud Jeansen added a comment -

        I had some more time to stress test this change with a few hundred PDF files.
        This patch doesn't regress any document AFAICT, and it also improves significantly a few borderline PDFs, namely :

        I would be happy to get any feedback regarding this patch...

        Show
        Arnaud Jeansen added a comment - I had some more time to stress test this change with a few hundred PDF files. This patch doesn't regress any document AFAICT, and it also improves significantly a few borderline PDFs, namely : http://www.stillhq.com/pdfdb/000122/info.html http://www.stillhq.com/pdfdb/000208/info.html http://www.stillhq.com/pdfdb/000627/info.html I would be happy to get any feedback regarding this patch...
        Hide
        Patrick Corless added a comment -

        Thanks for looking into this. I should be able to take a closer look at your patch this week. Is there any chance you could post a sample PDF file?

        Show
        Patrick Corless added a comment - Thanks for looking into this. I should be able to take a closer look at your patch this week. Is there any chance you could post a sample PDF file?
        Hide
        Arnaud Jeansen added a comment -

        Updated patch

        Show
        Arnaud Jeansen added a comment - Updated patch
        Hide
        Arnaud Jeansen added a comment -

        Hello Patrick,
        I attached the PDF file showing the problem and version 2 of the patch.

        Looking forward to your feedback.

        Show
        Arnaud Jeansen added a comment - Hello Patrick, I attached the PDF file showing the problem and version 2 of the patch. Looking forward to your feedback.
        Hide
        Patrick Corless added a comment -

        The patch looks really good. I'll make sure it gets in the next maintenance release. Thanks for you help.

        Show
        Patrick Corless added a comment - The patch looks really good. I'll make sure it gets in the next maintenance release. Thanks for you help.
        Hide
        Arnaud Jeansen added a comment -

        Hello Patrick,
        FYI, I got the corporate approval to sign the CLA and submitted it through the Icesoft email address minutes ago.

        Best regards,
        Arnaud

        Show
        Arnaud Jeansen added a comment - Hello Patrick, FYI, I got the corporate approval to sign the CLA and submitted it through the Icesoft email address minutes ago. Best regards, Arnaud
        Hide
        Arnaud Jeansen added a comment -

        Hello Patrick,
        Can you confirm the CLA was correctly received and that this patch will be included in 6.3.3?

        Thanks a lot,
        Arnaud

        Show
        Arnaud Jeansen added a comment - Hello Patrick, Can you confirm the CLA was correctly received and that this patch will be included in 6.3.3? Thanks a lot, Arnaud
        Hide
        Patrick Corless added a comment -

        Hi Arnaud;
        CLA was received, thank you. And yes the patch will be included in 6.3.3 will merge it into the trunk soon.

        Thanks again for your help.
        Patrick

        Show
        Patrick Corless added a comment - Hi Arnaud; CLA was received, thank you. And yes the patch will be included in 6.3.3 will merge it into the trunk soon. Thanks again for your help. Patrick

          People

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

            Dates

            • Created:
              Updated: