Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-58897

PDF export causes out of memory due to long indented numbered list in the page

    XMLWordPrintable

Details

    Description

      Summary

      PDF export can cause Out Of Memory if the page contains a long indented/nested numbered list.

      Steps to Reproduce

      1. Create a page
      2. Edit the storage format with Source Editor and add the contents of this file:
        • longindentedlist
          This is a long indented numbered list, eg:
          1.
              a.
          2.
              a.
              b.
              ...
          
      3. Export the page to PDF

      Expected Results

      The export completes.

      Actual Results

      This can be seen in the atlassian-confluence.log file on a server instance:

      2019-09-05 15:53:42,721 WARN [alert-dispatch:thread-1] [confluence.alert-log] log 1567709622608 ; WARNING ; JVM ; JVM-1002 ; Garbage collection exceeded time limit ; not-detected ;  ;  ; {"durationInMillis":5057,"windowInMillis":20000,"limitPercent":10,"threadMemoryAllocations":"","threadDump":[]}
      

      This can be seen in catalina.out:

      05-Sep-2019 15:35:02.592 INFO [http-nio-8090-exec-4] com.sun.jersey.server.impl.application.WebApplicationImpl._initiate Initiating Jersey application, version 'Jersey: 1.19.4 05/24/2017 03:20 PM'
      Exception in thread "http-nio-8090-exec-5" java.lang.OutOfMemoryError: Java heap space
          at java.util.Arrays.copyOf(Arrays.java:3332)
          at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
          at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:674)
          at java.lang.StringBuffer.append(StringBuffer.java:388)
          at org.xhtmlrenderer.css.newmatch.Matcher$Mapper.mapChild(Matcher.java:386)
          at org.xhtmlrenderer.css.newmatch.Matcher.matchElement(Matcher.java:154)
          at org.xhtmlrenderer.css.newmatch.Matcher.getMapper(Matcher.java:236)
          at org.xhtmlrenderer.css.newmatch.Matcher.getCascadedStyle(Matcher.java:86)
          at org.xhtmlrenderer.context.StyleReference.getCascadedStyle(StyleReference.java:204)
          at org.xhtmlrenderer.layout.SharedContext.getStyle(SharedContext.java:573)
          at org.xhtmlrenderer.layout.SharedContext.getStyle(SharedContext.java:552)
          at org.xhtmlrenderer.layout.BoxBuilder.createChildren(BoxBuilder.java:1096)
          at org.xhtmlrenderer.layout.BoxBuilder.createChildren(BoxBuilder.java:116)
          at org.xhtmlrenderer.render.BlockBox.ensureChildren(BlockBox.java:947)
      

      Notice that the renderer is in the process of parsing the numbered list based on the stack above (ensureChildren and createChildren methods).

      On a Data Center instance, the sandbox crashes while creating the export even if you increase its heap size significantly.

      Notes

      This problem does not affect versions below 6.13, which indicates it is related to the bug fix below:

      In 6.12 and earlier versions, the renderer does not identify the indented list and builds it as a normal numbered list, example:

      1. The following list in the Confluence page:
        1.
            a.
        2.
            a.
            b.
            ...
        
      2. Becomes this in the exported PDF:
        1.
            1.
        2.
            1.
            2.
            ...
        

      The export tool is now able to identify the indented list and render it. However, the side effect is that it may OOM if the list is too long.

      Workaround

      Remove the indented numbered list from the page or turn it into a normal numbered list (not indented) before exporting.

      Attachments

        Activity

          People

            Unassigned Unassigned
            bandreeti Bernardo Andreeti
            Votes:
            5 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated: