Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-628

OutOfMemoryError on pack200 NewAttributeBands.readNextUnionCase

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.21
    • 1.22
    • Archivers
    • None
    • ubuntu18, java-11-openjdk-amd64

    Description

      Similar to https://issues.apache.org/jira/browse/COMPRESS-626

      pack200.NewAttributeBands.readNextUnionCase can result in an infinite loop that finally leads to an out of memory error.

      import org.apache.commons.compress.harmony.pack200.*;
      
      public class ApacheCompress_1_22_90a4d8b3_OutOfMemory {
          public static void main(String[] args) throws Exception {
              CPUTF8 name = new CPUTF8("");
              CPUTF8 layout = new CPUTF8("Re\\T");
              new NewAttributeBands(1, null, null,
                      new AttributeDefinitionBands.AttributeDefinition(35, AttributeDefinitionBands.CONTEXT_CLASS, name, layout)
              );
          }
      }
       

       

      exception on 1.22 snapshot commit(90a4d8b3)

      Exception in thread "main" java.lang.OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects 

      exception on  1.21

      java.lang.OutOfMemoryError: Java heap space
              at java.base/java.util.Arrays.copyOf(Arrays.java:3745)
              at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:172)
              at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:748)
              at java.base/java.lang.StringBuffer.append(StringBuffer.java:429)
              at org.apache.commons.compress.harmony.pack200.NewAttributeBands.getStreamUpToMatchingBracket(NewAttributeBands.java:822)
              at org.apache.commons.compress.harmony.pack200.NewAttributeBands.readNextUnionCase(NewAttributeBands.java:304)
              at org.apache.commons.compress.harmony.pack200.NewAttributeBands.readNextLayoutElement(NewAttributeBands.java:237)
              at org.apache.commons.compress.harmony.pack200.NewAttributeBands.readNextAttributeElement(NewAttributeBands.java:184)
              at org.apache.commons.compress.harmony.pack200.NewAttributeBands.parseLayout(NewAttributeBands.java:95)
              at org.apache.commons.compress.harmony.pack200.NewAttributeBands.<init>(NewAttributeBands.java:53)
              at ApacheCompress_1_22_90a4d8b3_OutOfMemory.main(ApacheCompress_1_22_90a4d8b3_OutOfMemory.java:7) 

      Attachments

        Activity

          People

            Unassigned Unassigned
            infandrew Andrii Hudz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: