You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Martin Hilpert (JIRA)" <ji...@apache.org> on 2010/09/01 13:06:54 UTC

[jira] Created: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
------------------------------------------------------------

                 Key: PDFBOX-808
                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
             Project: PDFBox
          Issue Type: Bug
          Components: FontBox
    Affects Versions: 1.2.1
         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
            Reporter: Martin Hilpert
            Priority: Blocker


Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:

   java.lang.Thread.State: RUNNABLE
	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)

It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Martin Hilpert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12907194#action_12907194 ] 

Martin Hilpert commented on PDFBOX-808:
---------------------------------------

Tested with

pdfbox-1.3.0-20100907.220349-33.jar
fontbox-1.3.0-20100907.220349-34.jar

=> yahoo! Works! :-)


> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Assignee: Jukka Zitting
>            Priority: Critical
>             Fix For: 1.3.0
>
>         Attachments: nbrm____.zip
>
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Martin Hilpert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906049#action_12906049 ] 

Martin Hilpert commented on PDFBOX-808:
---------------------------------------

Ehm, you just exchanged

        while( (amountRead = read( data, totalAmountRead, numberOfBytes-totalAmountRead ) ) != -1 &&  totalAmountRead < numberOfBytes ) 
        { 
            totalAmountRead += amountRead; 

with

        while(totalAmountRead < numberOfBytes && (amountRead = read( data, totalAmountRead, numberOfBytes-totalAmountRead ) ) != -1 ) 
        { 
            totalAmountRead += amountRead; 

How should this change anything? This is a boolean AND operation so both operands need to be true. And even though "amountRead" might be changed, this doesn't change anything for the whole loop condition. Can you supply a current JAR so that I can test it? (Then I don't have to go through the process of learning how to check the source out, compile it hopefully without erros.)

> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Assignee: Jukka Zitting
>            Priority: Critical
>             Fix For: 1.3.0
>
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Martin Hilpert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905449#action_12905449 ] 

Martin Hilpert edited comment on PDFBOX-808 at 9/2/10 4:27 AM:
---------------------------------------------------------------

Nope, it happens occasionally for arbitrary PDFs (that are generated before with Apache FOP). I load a PDF file and try to add additional text to it - with a custom font.

      was (Author: mhilpert):
    Nope, it happens occasionally for arbitrary PDFs. I load a PDF file and try to add additional text to it - with a custom font.
  
> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Priority: Critical
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906986#action_12906986 ] 

Jukka Zitting commented on PDFBOX-808:
--------------------------------------

Thanks for the attachment! I debugged the parsing process and found out that the font file uses glyph name indexes in the reserved range from 32768 to 65535 (see version 2.0 in http://www.microsoft.com/typography/otspec/post.htm). The parsing algorithm in FontBox was not prepared to handle such reserved glyph name indexes,  which is why it ended up trying to read past the end of the font file. I fixed that in revision 993541 by making the parser explicitly ignore such reserved glyph name indexes.

> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Assignee: Jukka Zitting
>            Priority: Critical
>             Fix For: 1.3.0
>
>         Attachments: nbrm____.zip
>
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Martin Hilpert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905449#action_12905449 ] 

Martin Hilpert commented on PDFBOX-808:
---------------------------------------

Nope, it happens occasionally for arbitrary PDFs. I load a PDF file and try to add additional text to it - with a custom font.

> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Priority: Critical
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jukka Zitting resolved PDFBOX-808.
----------------------------------

         Assignee: Jukka Zitting
    Fix Version/s: 1.3.0
       Resolution: Fixed

There was indeed a potential for an endless loop. I fixed that in revision 992278 by switching the order of the loop conditions.

> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Assignee: Jukka Zitting
>            Priority: Critical
>             Fix For: 1.3.0
>
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906453#action_12906453 ] 

Jukka Zitting commented on PDFBOX-808:
--------------------------------------

Can you attach the troublesome ttf file?

> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Assignee: Jukka Zitting
>            Priority: Critical
>             Fix For: 1.3.0
>
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Martin Hilpert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905449#action_12905449 ] 

Martin Hilpert edited comment on PDFBOX-808 at 9/2/10 5:34 AM:
---------------------------------------------------------------

Nope, it happens occasionally for arbitrary PDFs (that are generated before with Apache FOP). I load a PDF file and try to add additional text to it - with a custom font.

Okay, I am able to reproduce it: it's a specific TTF font! PDTrueTypeFont.loadTTF() blocks with the stack trace I posted above. The font is called "nbrm____.ttf" ("NewBaskervilleEF-Roman (TrueType").

By the way: this font make no problems in other applications.

      was (Author: mhilpert):
    Nope, it happens occasionally for arbitrary PDFs (that are generated before with Apache FOP). I load a PDF file and try to add additional text to it - with a custom font.
  
> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Priority: Critical
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler updated PDFBOX-808:
--------------------------------------

    Priority: Critical  (was: Blocker)

> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Priority: Critical
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906119#action_12906119 ] 

Jukka Zitting commented on PDFBOX-808:
--------------------------------------

You're right, that was some sloppy thinking by me. I was just looking at protecting against the "numberOfBytes-totalAmountRead" argument being zero, but of course even in such cases the second half of the AND condition would have broken the loop after one unnecessary read() call.

It turns out that the problem was in the MemoryTTFDataStream class that would return 0 instead of -1 when the end of the stream is reached. That shouldn't normally be a problem given the way TTF files are parsed, but will cause the infinite loop when dealing with a truncated or otherwise malformed file. I fixed this problem in revision 992483, and made TTFDataStream.read(int) throw an IOException in case such an unexpected end of the TTF stream is encountered.

You can get the latest snapshot jars from https://repository.apache.org/content/groups/snapshots-group/org/apache/pdfbox/. Our CI build will push a new version up there within an hour or so.

> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Assignee: Jukka Zitting
>            Priority: Critical
>             Fix For: 1.3.0
>
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Martin Hilpert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905472#action_12905472 ] 

Martin Hilpert commented on PDFBOX-808:
---------------------------------------

When I look at org.apache.fontbox.ttf.TTFDataStream.java:

-------------
    public byte[] read( int numberOfBytes ) throws IOException
    {
        byte[] data = new byte[ numberOfBytes ];
        int amountRead = 0;
        int totalAmountRead = 0;
        while( (amountRead = read( data, totalAmountRead, numberOfBytes-totalAmountRead ) ) != -1 && 
               totalAmountRead < numberOfBytes )
        {
            totalAmountRead += amountRead;    //<<<<<<< HERE !!!!!!!!
            //read at most numberOfBytes bytes from the stream.
        }
        return data;
    }
-----------------

The thread dump shows 

 totalAmountRead += amountRead

as the place where it "hangs". When I look at jVisualVM's monitors, it shows 50% CPU usage (as the VM only has this 1 thread, it means that PDFBox uses 100% of 1 of the 2 cores). So this seems like an endless loop. Memory consumption slowly increases just to drop after 7 minutes (probably when the garbage collector cleans up).

The file "nbrm____.ttf" is only 97 KB of size. Something seems to be broken ...


> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Priority: Critical
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905003#action_12905003 ] 

Andreas Lehmkühler commented on PDFBOX-808:
-------------------------------------------

Is this issue always triggered by the same pdf? What exactly are you doing, text extrcation, rendering, creating a new pdf?

> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Priority: Blocker
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Martin Hilpert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905449#action_12905449 ] 

Martin Hilpert edited comment on PDFBOX-808 at 9/2/10 5:50 AM:
---------------------------------------------------------------

Nope, it happens occasionally for arbitrary PDFs (that are generated before with Apache FOP). I load a PDF file and try to add additional text to it - with a custom font.

Okay, I am able to reproduce it: it's a specific TTF font! PDTrueTypeFont.loadTTF() blocks with the stack trace I posted above. The font is called "nbrm____.ttf" ("NewBaskervilleEF-Roman (TrueType").

By the way: this font make no problems in other applications. E.g. another application still use iText 2.1.7 to also add text to PDFs. And this application use the same font source directory. The very same font file has no probelm there.

      was (Author: mhilpert):
    Nope, it happens occasionally for arbitrary PDFs (that are generated before with Apache FOP). I load a PDF file and try to add additional text to it - with a custom font.

Okay, I am able to reproduce it: it's a specific TTF font! PDTrueTypeFont.loadTTF() blocks with the stack trace I posted above. The font is called "nbrm____.ttf" ("NewBaskervilleEF-Roman (TrueType").

By the way: this font make no problems in other applications.
  
> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Priority: Critical
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-808) PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)

Posted by "Martin Hilpert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906447#action_12906447 ] 

Martin Hilpert commented on PDFBOX-808:
---------------------------------------

I teste with 

pdfbox-1.3.0-20100905.174656-31.jar
fontbox-1.3.0-20100905.174656-32.jar

and now I get this Exception:

----------------------------------------------------
    java.io.IOException: Unexpected end of TTF stream reached
    	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:200)
    	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
    	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
    	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
    	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
    	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
    	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
    	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
    	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
    	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
------------------------------------------------

which is of course better than freezing. But it doesn't help me much further as other apps don't have problems with this font. So I guess, there might be some other problem in PDFBox reading fonts.

> PDTrueTypeFont.loadTTF() freezes (at TTFDataStream.java:195)
> ------------------------------------------------------------
>
>                 Key: PDFBOX-808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-808
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.2.1
>         Environment: PDFBox 1.2.1, JDK 1.6.0_21, Windows XP 32 Bit.
>            Reporter: Martin Hilpert
>            Assignee: Jukka Zitting
>            Priority: Critical
>             Fix For: 1.3.0
>
>
> Sometimes (not always), my app "freezes". When I look into jVisualVM thread dump, I see this stack trace:
>    java.lang.Thread.State: RUNNABLE
> 	at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:195)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
> 	at org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
> 	at org.apache.fontbox.ttf.PostScriptTable.initData(PostScriptTable.java:104)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:140)
> 	at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:87)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:206)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:167)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:143)
> 	at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:130)
> It never returns and blocks the application from continuing. This hapend several times now every few hours.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.