[ https://issues.apache.org/jira/browse/PDFBOX-5460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17554892#comment-17554892 ]
Tilman Hausherr edited comment on PDFBOX-5460 at 6/16/22 4:18 PM: ------------------------------------------------------------------ Thanks for the detailed trace. Ouch. >From what I understand, {{getGlyph()}} is the bad actor here when it's calling >{{getGlyphData()}} which loads the hmtx table. The data object is used for >synchronization in two different classes, obscuring all this further. A >solution would be to get the hmtx table first, before "data" is getting >locked. I.e. FIRST the truetype font object, THEN then the data object, never >the other way around. was (Author: tilman): Thanks for the detailed trace. Ouch. >From what I understand, {{getGlyph()}} is the bad actor here when it's calling >{{getGlyphData()}} which loads the hmtx table. A solution would be to get the >hmtx table first, before "data" is getting locked. I.e. FIRST the truetype >font object, THEN then the data object, never the other way around. > Deadlock in TrueTypeFont and RAFDataStream > ------------------------------------------ > > Key: PDFBOX-5460 > URL: https://issues.apache.org/jira/browse/PDFBOX-5460 > Project: PDFBox > Issue Type: Bug > Components: FontBox > Affects Versions: 2.0.26 > Reporter: Ram Lakshmanan > Priority: Major > Labels: deadlock > Fix For: 2.0.27, 3.0.0 PDFBox > > > Deadlock is happening between *org.apache.fontbox.ttf.RAFDataStream* and > *org.apache.fontbox.ttf.TrueTypeFont* objects. Below is the stack trace of > the two threads which are in deadlock. If you want to see the complete thread > dump you can [refer it > here|https://fastthread.io/my-thread-report.jsp?p=c2hhcmVkLzIwMjIvMDYvMTUvLS1wZGYtYm94LWRlYWRsb2NrLnppcC0tMjItMjQtNTc=&s=t]. > > {code:java} > APP_Thread_50408_759_100162222_WorkerTask_1652842343227_P_Th_SPR-APP-pool-5-thread-6 > PRIORITY : 5 > THREAD ID : 0X00007F894C406000 > NATIVE ID : 0X44D1 > NATIVE ID (DECIMAL) : 17617 > STATE : BLOCKED > stackTrace: > java.lang.Thread.State: BLOCKED (on object monitor) > at org.apache.fontbox.ttf.TrueTypeFont.getTable(TrueTypeFont.java:147) > - waiting to lock <0x00000002d216fec8> (a org.apache.fontbox.ttf.TrueTypeFont) > at > org.apache.fontbox.ttf.TrueTypeFont.getHorizontalMetrics(TrueTypeFont.java:229) > at org.apache.fontbox.ttf.GlyphTable.getGlyphData(GlyphTable.java:210) > at org.apache.fontbox.ttf.GlyphTable.getGlyph(GlyphTable.java:191) > - locked <0x00000002d218ca28> (a org.apache.fontbox.ttf.RAFDataStream) > at org.apache.fontbox.ttf.TrueTypeFont.getPath(TrueTypeFont.java:676) > at org.apache.pdfbox.pdmodel.font.PDType1Font.getPath(PDType1Font.java:638) > at > org.apache.pdfbox.rendering.Type1Glyph2D.getPathForCharacterCode(Type1Glyph2D.java:83) > at org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(PageDrawer.java:495) > at org.apache.pdfbox.rendering.PageDrawer.showFontGlyph(PageDrawer.java:476) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:787) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:805) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:743) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.showTextString(PDFStreamEngine.java:606) > at > org.apache.pdfbox.contentstream.operator.text.ShowText.process(ShowText.java:56) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:933) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:514) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:492) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:155) > at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:277) > at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:347) > at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:268) > at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:228) > at > xxxxxxx.export.service.thumbnail.PDFSlideGeneratorServiceImpl$1.call(PDFSlideGeneratorServiceImpl.java:60) > at > xxxxxxx.ops.executor.util.ParallelExecutorTask.doCall(ParallelExecutorTask.java:43) > at > xxxxxxx.ops.executor.util.ParallelExecutor.executeTaskFromQueue(ParallelExecutor.java:154) > at > xxxxxxx.ops.executor.util.ParallelExecutor.access$100(ParallelExecutor.java:26) > at > xxxxxxx.ops.executor.util.ParallelExecutor$WorkerTask.doCall(ParallelExecutor.java:164) > at > xxxxxxx.ops.executor.util.UserContextAwareCallable.call(UserContextAwareCallable.java:89) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) > at java.lang.Thread.run(Thread.java:748) > APP_Thread_50408_759_100162222_WorkerTask_1652842343227_P_Th_SPR-APP-pool-5-thread-5 > PRIORITY : 5 > THREAD ID : 0X00007F894C404800 > NATIVE ID : 0X44D0 > NATIVE ID (DECIMAL) : 17616 > STATE : BLOCKED > stackTrace: > java.lang.Thread.State: BLOCKED (on object monitor) > at org.apache.fontbox.ttf.TrueTypeFont.readTable(TrueTypeFont.java:356) > - waiting to lock <0x00000002d218ca28> (a > org.apache.fontbox.ttf.RAFDataStream) > at org.apache.fontbox.ttf.TrueTypeFont.getTable(TrueTypeFont.java:150) > - locked <0x00000002d216fec8> (a org.apache.fontbox.ttf.TrueTypeFont) > at org.apache.fontbox.ttf.TrueTypeFont.getCmap(TrueTypeFont.java:262) > at > org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapImpl(TrueTypeFont.java:556) > at > org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapLookup(TrueTypeFont.java:541) > at org.apache.fontbox.ttf.TrueTypeFont.nameToGID(TrueTypeFont.java:629) > at org.apache.fontbox.ttf.TrueTypeFont.hasGlyph(TrueTypeFont.java:698) > at > org.apache.pdfbox.pdmodel.font.PDType1Font.getNameInFont(PDType1Font.java:601) > at org.apache.pdfbox.pdmodel.font.PDType1Font.hasGlyph(PDType1Font.java:645) > at > org.apache.pdfbox.rendering.Type1Glyph2D.getPathForCharacterCode(Type1Glyph2D.java:59) > at org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(PageDrawer.java:495) > at org.apache.pdfbox.rendering.PageDrawer.showFontGlyph(PageDrawer.java:476) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:787) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:805) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:743) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.showTextString(PDFStreamEngine.java:606) > at > org.apache.pdfbox.contentstream.operator.text.ShowText.process(ShowText.java:56) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:933) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:514) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:492) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:155) > at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:277) > at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:347) > at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:268) > at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:228) > at > xxxxxxx.export.service.thumbnail.PDFSlideGeneratorServiceImpl$1.call(PDFSlideGeneratorServiceImpl.java:60) > at > xxxxxxx.ops.executor.util.ParallelExecutorTask.doCall(ParallelExecutorTask.java:43) > at > xxxxxxx.ops.executor.util.ParallelExecutor.executeTaskFromQueue(ParallelExecutor.java:154) > at > xxxxxxx.ops.executor.util.ParallelExecutor.access$100(ParallelExecutor.java:26) > at > xxxxxxx.ops.executor.util.ParallelExecutor$WorkerTask.doCall(ParallelExecutor.java:164) > at > xxxxxxx.ops.executor.util.UserContextAwareCallable.call(UserContextAwareCallable.java:89) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) > at java.lang.Thread.run(Thread.java:748) {code} > > -- This message was sent by Atlassian Jira (v8.20.7#820007) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org