Uploaded image for project: 'Tika'
  1. Tika
  2. TIKA-1631

OutOfMemoryException in ZipContainerDetector

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.8
    • 1.15
    • detector
    • None

    Description

      When I try to detect ZIP container I rarely get this exception. It is caused by the fact that the file looks like ZIP container (magics), but in fact its random noise. So Apache decompress tries to find the size of tables (expects correct stream), loads coincidentally huge number (as on the given place there can be anything in the stream) and tries to allocate array of several GB in size (hence the exception).

      This bug negatively influences stability of systems running Tika, as the decompressor can accidentally allocate as much memory as is available and other parts of the system then might not be able to allocate their objects.

      A solution might be to add additional parameter to Tika config that would limit size of these arrays. If the size would be bigger, it would throw exception. This change should not be hard, as method InternalLZWInputStream.initializeTables() is protected.

      Exception in thread "pool-2-thread-2" java.lang.OutOfMemoryError: Java heap space
      at org.apache.commons.compress.compressors.z.internal.InternalLZWInputStream.initializeTables(InternalLZWInputStream.java:111)
      at org.apache.commons.compress.compressors.z.ZCompressorInputStream.<init>(ZCompressorInputStream.java:52)
      at org.apache.commons.compress.compressors.CompressorStreamFactory.createCompressorInputStream(CompressorStreamFactory.java:186)
      at org.apache.tika.parser.pkg.ZipContainerDetector.detectCompressorFormat(ZipContainerDetector.java:106)
      at org.apache.tika.parser.pkg.ZipContainerDetector.detect(ZipContainerDetector.java:92)
      at org.apache.tika.detect.CompositeDetector.detect(CompositeDetector.java:61)

      Attachments

        1. cache.mpgindex
          0.0 kB
          Thorsten Schäfer

        Issue Links

          Activity

            People

              Unassigned Unassigned
              malejpavouk Pavel Micka
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: