Application Crashes when Getting Slide Thumbnail in Java

We are getting crash dumps when generating thumb nails via slides. I have included part of the hs_err dump file

Stack: [0x00007fe819dde000,0x00007fe819edf000], sp=0x00007fe819eda008, free space=1008k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libc.so.6+0x14be20] __memcpy_ssse3+0x90
C [libfreetype.so.6+0x1e0b8] FT_Stream_EnterFrame+0x88

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 27543 sun.font.FreetypeFontScaler.getGlyphImageNative(Lsun/font/Font2D;JJI)J (0 bytes) @ 0x00007fe8ae996a4c [0x00007fe8ae996a00+0x4c]
J 54580 C2 sun.font.FreetypeFontScaler.getGlyphImage(JI)J (39 bytes) @ 0x00007fe8b0f2d7dc [0x00007fe8b0f2d700+0xdc]
J 34273 C2 sun.font.FileFontStrike.getGlyphImagePtr(I)J (126 bytes) @ 0x00007fe8b0258fe0 [0x00007fe8b0258ec0+0x120]
J 43578 C2 sun.font.FileFontStrike.getGlyphMetrics(I)Ljava/awt/geom/Point2D$Float; (7 bytes) @ 0x00007fe8af72c5a0 [0x00007fe8af72c4e0+0xc0]
v ~StubRoutines::call_stub
J 34094 sun.font.SunLayoutEngine.nativeLayout(Lsun/font/Font2D;Lsun/font/FontStrike;[FII[CIIIIIIILjava/awt/geom/Point2D$Float;Lsun/font/GlyphLayout$GVData;JJ)V (0 bytes) @ 0x00007fe8b0e2e8a9 [0x00007fe8b0e2e780+0x129]
J 50490 C2 sun.font.GlyphLayout.layout(Ljava/awt/Font;Ljava/awt/font/FontRenderContext;[CIIILsun/font/StandardGlyphVector;)Lsun/font/StandardGlyphVector; (688 bytes) @ 0x00007fe8b35d0a8c [0x00007fe8b35cf9c0+0x10cc]
J 45827 C2 java.awt.font.TextLine.init()V (1056 bytes) @ 0x00007fe8b2d41a9c [0x00007fe8b2d41460+0x63c]
J 45832 C2 java.awt.font.TextMeasurer.makeTextLineOnRange(II)Ljava/awt/font/TextLine; (82 bytes) @ 0x00007fe8b2d338dc [0x00007fe8b2d33720+0x1bc]
J 43970 C2 com.aspose.slides.vw.do(Lcom/aspose/slides/internal/ft/else;Ljava/lang/String;Lcom/aspose/slides/internal/fs/this;IFLcom/aspose/slides/internal/fs/double;[F)V (113 bytes) @ 0x00007fe8b28f0f10 [0x00007fe8b28ef5e0+0x1930]
J 52674 C2 com.aspose.slides.vw.do(Ljava/lang/String;Lcom/aspose/slides/internal/fs/return;Lcom/aspose/slides/TextParam;Lcom/aspose/slides/ql;)V (1946 bytes) @ 0x00007fe8b3eade54 [0x00007fe8b3eabee0+0x1f74]
J 53678 C2 com.aspose.slides.vw.do(Ljava/lang/String;Lcom/aspose/slides/internal/fs/return;Lcom/aspose/slides/TextParam;)V (261 bytes) @ 0x00007fe8ae7e86f8 [0x00007fe8ae7e8560+0x198]
J 34322 C1 com.aspose.slides.aq3.do(Lcom/aspose/slides/du;Ljava/lang/String;Lcom/aspose/slides/internal/fs/return;Lcom/aspose/slides/TextParam;Lcom/aspose/slides/aly;Lcom/aspose/slides/TextFrame;)V (241 bytes) @ 0x00007fe8b0eb6bbc [0x00$
J 59160 C1 com.aspose.slides.at3.do(Lcom/aspose/slides/du;Ljava/lang/String;Lcom/aspose/slides/internal/fs/return;Lcom/aspose/slides/TextParam;Lcom/aspose/slides/aly;)Ljava/lang/String; (1408 bytes) @ 0x00007fe8b49ad26c [0x00007fe8b49a2$
J 59185 C1 com.aspose.slides.at3.do(Lcom/aspose/slides/du;Lcom/aspose/slides/zz;Lcom/aspose/slides/k0;)V (467 bytes) @ 0x00007fe8b4c48eb4 [0x00007fe8b4c45180+0x3d34]
J 59167 C1 com.aspose.slides.at3.do(Lcom/aspose/slides/du;Lcom/aspose/slides/aly;Lcom/aspose/slides/xu;Lcom/aspose/slides/axj;Z[ILcom/aspose/slides/ov;[Z)V (3416 bytes) @ 0x00007fe8b4d52d54 [0x00007fe8b4d2cb40+0x26214]
J 55107 C2 com.aspose.slides.at3.do(Lcom/aspose/slides/du;Lcom/aspose/slides/aly;)V (320 bytes) @ 0x00007fe8b27ea554 [0x00007fe8b27e9b40+0xa14]
J 55365 C2 com.aspose.slides.atu.do(Lcom/aspose/slides/du;Lcom/aspose/slides/aly;)Z (342 bytes) @ 0x00007fe8af6058ec [0x00007fe8af605880+0x6c]
J 43339 C1 com.aspose.slides.t.do(Lcom/aspose/slides/du;Lcom/aspose/slides/aly;Lcom/aspose/slides/InterruptionToken;)V (985 bytes) @ 0x00007fe8b26adf74 [0x00007fe8b26a6a60+0x7514]
J 51118 C1 com.aspose.slides.s6.do(Lcom/aspose/slides/du;Lcom/aspose/slides/aly;Lcom/aspose/slides/InterruptionToken;)V (363 bytes) @ 0x00007fe8b1b28dd4 [0x00007fe8b1b26100+0x2cd4]
j com.aspose.slides.api.for(Lcom/aspose/slides/du;Lcom/aspose/slides/aly;Lcom/aspose/slides/InterruptionToken;)V+13
j com.aspose.slides.api.do(Lcom/aspose/slides/du;Lcom/aspose/slides/IShapeFrame;Lcom/aspose/slides/internal/fn/do;Lcom/aspose/slides/ly;Lcom/aspose/slides/InterruptionToken;)V+374
j com.aspose.slides.api.do(Lcom/aspose/slides/du;Lcom/aspose/slides/internal/fn/do;Lcom/aspose/slides/ly;Lcom/aspose/slides/InterruptionToken;)V+7
j com.aspose.slides.api.do(Lcom/aspose/slides/internal/fs/default;)Lcom/aspose/slides/internal/fs/if;+218
j com.aspose.slides.Slide.do(Lcom/aspose/slides/internal/fs/default;)Lcom/aspose/slides/internal/fs/if;+8
j com.aspose.slides.Slide.for(FF)Lcom/aspose/slides/internal/fs/if;+79
j com.aspose.slides.Slide.getThumbnail(FF)Ljava/awt/image/BufferedImage;+3

@bjenkin,
Thank you for contacting support.

Please check your results using the latest version of Aspose.Slides if it is possible. If the issue persists, please share the following data and information:

  • presentation file (you can zip the file and upload it here)
  • code example that reproduces the error
  • OS version where the code was executed
  • JDK version in your app
  • Aspose.Slides version you used

As this is a production issue and lots of files are processed we cannot know for sure the actual file that was used. This happens often. this would imply and uncaught exception somewhere in the apose code base.

Apose 22.5
Java OpenJDK Runtime Environment (build 1.8.0_201-b09)
Centos 7 Linux 3.10.0-957.10.1.el7.x86_64

public void generateThumbnail(String key, String clientID, int uid, byte[] contents, String guid, int version) throws Throwable {

    try {
        CWAmazonS3 s3Client = awsClientService.getS3Client(key, clientID, AWSClientService.DAMSTORETYPE);

        ByteArrayOutputStream convertPowerPointToPDF = AsposeUtility.convertPowerPointToPDF(new ByteArrayInputStream(contents), contentWelderFontManager.getFullFontFolderPath()+File.separatorChar+clientID);
        if (convertPowerPointToPDF!=null) {
            byte[] convertPowerPointToPDFByteArray = convertPowerPointToPDF.toByteArray();
            s3Client.putObject(guid+"/"+version+"/"+"contents.pdf", new ByteArrayInputStream(convertPowerPointToPDFByteArray), convertPowerPointToPDFByteArray.length, MediaType.APPLICATION_PDF_VALUE);

            AsposeUtility.loadLicenseFile("com.aspose.slides");
            Presentation pres = null;
            if (contentWelderFontManager.getFullFontFolderPath()!=null) {
                com.aspose.slides.LoadOptions loadOptions = new com.aspose.slides.LoadOptions();
                IFontSources documentLevelFontSources = loadOptions.getDocumentLevelFontSources();
                documentLevelFontSources.setFontFolders(new String[]{contentWelderFontManager.getFullFontFolderPath()+File.separatorChar+clientID});
                pres = new Presentation(new ByteArrayInputStream(contents), loadOptions);
            } else {
                pres = new Presentation(new ByteArrayInputStream(contents));
            }

            // Access the first slide
            int slidesToRender = pres.getSlides().size();
            for (int i=0;i<slidesToRender; ++i) {
                com.aspose.slides.ISlide sld = pres.getSlides().get_Item(i);
                // Create a full scale image
                BufferedImage image = sld.getThumbnail(1f, 1f);

                // Save the image to disk in PNG format
                try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { 
                    ImageIO.write(image, "png", baos);
                    byte[] thumbnail = baos.toByteArray();
                    ByteArrayResourceFilename thumbnailSmall = imageThumbnailGenerator.generateThumbnail(key, clientID, uid, new ByteArrayResourceFilename(thumbnail, "", MediaType.IMAGE_PNG_VALUE), 250, 96);
                    ByteArrayResourceFilename thumbnailLarge = imageThumbnailGenerator.generateThumbnail(key, clientID, uid, new ByteArrayResourceFilename(thumbnail, "", MediaType.IMAGE_PNG_VALUE), 1200, 96);
                    if (i==0) {
                        s3Client.putObject(guid+"/"+version+"/"+"thumbnailSmall", thumbnailSmall.getInputStream(), thumbnailSmall.getByteArray().length, MediaType.IMAGE_PNG_VALUE);
                        s3Client.putObject(guid+"/"+version+"/"+"thumbnailLarge", thumbnailLarge.getInputStream(), thumbnailLarge.getByteArray().length, MediaType.IMAGE_PNG_VALUE);
                        damItemDataServices.updateVersionItemThumbnail(key, clientID, uid, guid, version);
                        damItemDataServices.swapDAMItemStatus(key, clientID, uid, guid, "generatingThumbnail", "generatingPageThumbnail", "Generating Page Thumbnails");
                    }
                    s3Client.putObject(guid+"/"+version+"/"+"page"+i, thumbnailSmall.getInputStream(), thumbnailSmall.getByteArray().length, MediaType.IMAGE_PNG_VALUE);
                    s3Client.putObject(guid+"/"+version+"/"+"page"+i+"Large", thumbnailLarge.getInputStream(), thumbnailLarge.getByteArray().length, MediaType.IMAGE_PNG_VALUE);
                } catch (IOException e) {
                }
            }
        }
    } catch (Throwable th) {
        logger.error(ExceptionUtils.getFullStackTrace(th));
    } finally {
        damItemDataServices.removeDAMItemStatus(key, clientID, uid, guid, "generatingThumbnail");
        damItemDataServices.removeDAMItemStatus(key, clientID, uid, guid, "generatingPageThumbnail");
    }
}

@bjenkin,
Thank you for the additional information. I’ve added a ticket with ID SLIDESJAVA-38847 to our issue tracking system. Our development team will review your code and the error dump. We will inform you of any progress.

@bjenkin,
Our developers have reviewed your code and the error dump. Because the exception related to JDK/libfreetype version, please try to use the latest JDK and/or update libfreetype.