← Back to team overview

openjdk team mailing list archive

Bug#717856: openjdk-7-jre: overflows heap when attempting to log backtraces with Log4J 2

 

Package: openjdk-7-jre
Version: 7u25-2.3.10-1~deb7u1
Severity: normal

Hi there,

I am unable to run a simple program using the Log4J 2 API.  The same program
runs on other JVMs without issues, including the OpenJDK 7u3 version in stable.
The update from wheezy-security to 7u21 appears to have caused this issue.

The program is as such:

  package ic.log4j2test;

  import java.io.IOException;
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;

  public class Log4j2Test {
      private static Logger log = LogManager.getLogger("Hello");
      public static void main(String[] args) {
          try {
              log.error("INSIDE TRY BLOCK");
              throw new IOException("KILLAH");
          } catch (IOException e) {
              log.error("WHUT", e);
          }
      }
  }

When running this with the most recent version of Log4j 2, it runs for about a
minute, producing the following output:

  amoe@kruis $ java -jar log4j2-test-1-jar-with-dependencies.jar 
  11:28:17.622 [main] ERROR Hello - INSIDE TRY BLOCK
  Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
          at java.util.Arrays.copyOf(Arrays.java:2245)
          at java.util.Arrays.copyOf(Arrays.java:2219)
          at java.util.Vector.grow(Vector.java:262)
          at java.util.Vector.ensureCapacityHelper(Vector.java:242)
          at java.util.Vector.addElement(Vector.java:616)
          at java.util.Stack.push(Stack.java:67)
          at org.apache.logging.log4j.core.impl.ThrowableProxy.getCurrentStack(ThrowableProxy.java:297)
          at org.apache.logging.log4j.core.impl.ThrowableProxy.<init>(ThrowableProxy.java:69)
          at org.apache.logging.log4j.core.impl.Log4jLogEvent.<init>(Log4jLogEvent.java:112)
          at org.apache.logging.log4j.core.impl.Log4jLogEvent.<init>(Log4jLogEvent.java:83)
          at org.apache.logging.log4j.core.impl.DefaultLogEventFactory.createEvent(DefaultLogEventFactory.java:49)
          at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:366)
          at org.apache.logging.log4j.core.Logger.log(Logger.java:110)
          at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:609)
          at ic.log4j2test.Log4j2Test.main(Log4j2Test.java:15)

I expect the following output:

  10:30:40.716 [main] ERROR Hello - INSIDE TRY BLOCK
  10:30:40.718 [main] ERROR Hello - WHUT
  java.io.IOException: KILLAH
          at ic.log4j2test.Log4j2Test.main(Log4j2Test.java:13) [log4j2-test-1-jar-with-dependencies.jar:?]

I'm not sure if this is a bug in Log4j 2, or in the JVM itself, but I am
currently only able to reproduce it with this version of the Debian JVM.  There
is a Maven project available at <https://gist.github.com/amoe/6069573> if you
want to run the test yourself.

Cheers,
Dave

-- System Information:
Debian Release: 7.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages openjdk-7-jre depends on:
ii  libasound2                1.0.25-4
ii  libatk-wrapper-java-jni   0.30.4-3
ii  libatk1.0-0               2.4.0-2
ii  libc6                     2.13-38
ii  libcairo2                 1.12.2-3
ii  libcups2                  1.5.3-5
ii  libfontconfig1            2.9.0-7.1
ii  libfreetype6              2.4.9-1.1
ii  libgdk-pixbuf2.0-0        2.26.1-1
ii  libgif4                   4.1.6-10
ii  libgl1-mesa-glx [libgl1]  8.0.5-4+deb7u2
ii  libglib2.0-0              2.33.12+really2.32.4-5
ii  libgtk2.0-0               2.24.10-2
ii  libjpeg8                  8d-1
ii  libpango1.0-0             1.30.0-1
ii  libpng12-0                1.2.49-1
ii  libpulse0                 2.0-6.1
ii  libx11-6                  2:1.5.0-1+deb7u1
ii  libxext6                  2:1.3.1-2+deb7u1
ii  libxi6                    2:1.6.1-1+deb7u1
ii  libxinerama1              2:1.1.2-1+deb7u1
ii  libxrandr2                2:1.3.2-2+deb7u1
ii  libxrender1               1:0.9.7-1+deb7u1
ii  libxtst6                  2:1.2.1-1+deb7u1
ii  openjdk-7-jre-headless    7u25-2.3.10-1~deb7u1
ii  zlib1g                    1:1.2.7.dfsg-13

Versions of packages openjdk-7-jre recommends:
ii  libgconf2-4       3.2.5-1+build1
ii  libgnome2-0       2.32.1-3
ii  libgnomevfs2-0    1:2.24.4-2
ii  ttf-dejavu-extra  2.33-3

Versions of packages openjdk-7-jre suggests:
pn  icedtea-7-plugin  <none>

-- no debconf information