[ 
https://issues.apache.org/jira/browse/LOG4J2-3077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17324794#comment-17324794
 ] 

Ralph Goers commented on LOG4J2-3077:
-------------------------------------

This is going to be tough to diagnose without debugging it. Your application 
tried to log something that must have gotten an exception while logging it. 
Log4j then catches the exception and tries to log its own message to the status 
logger with the exception that it caught. That is then getting an exception. 
Log4j has a recursion counter in AbstractLogger to detect this but only Async 
Loggers check this since that would indicate that the RingBuffer is full. We 
have checks for recursive calls but those are in the AppenderControl since we 
aren't manipulating much data in the Loggers.

However, StatusLogger is a special Logger implementation. It has a hard-wired 
format and doesn't use Appenders, so there is not AppenderControl to protect 
from this.

> StackOverflowError on exception during logging
> ----------------------------------------------
>
>                 Key: LOG4J2-3077
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3077
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: SLF4J Bridge
>    Affects Versions: 2.14.1
>            Reporter: Lőrinc Pap
>            Priority: Major
>
> Sometimes we're getting the following logs:
> {code:java}
> Exception in thread "ratpack-shutdown-thread" java.lang.StackOverflowError
>     at 
> org.apache.logging.log4j.spi.AbstractLogger.getRecursionDepthHolder(AbstractLogger.java:2166)
>     at 
> org.apache.logging.log4j.spi.AbstractLogger.decrementRecursionDepth(AbstractLogger.java:2178)
>     at 
> org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2161)
>     at 
> org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2142)
>     at 
> org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2017)
>     at 
> org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1983)
>     at 
> org.apache.logging.log4j.spi.AbstractLogger.warn(AbstractLogger.java:2676)
>     at 
> org.apache.logging.log4j.spi.AbstractLogger.handleLogMessageException(AbstractLogger.java:2235)
>     at 
> org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2208)
> ...{code}
> and
> {code:java}
>  Exception in thread "ratpack-shutdown-thread" java.lang.OutOfMemoryError: 
> Java heap space
>         at java.util.Arrays.copyOf(Unknown Source)
>         at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown 
> Source)
>         at java.lang.AbstractStringBuilder.append(Unknown Source)
>         at java.lang.StringBuilder.append(Unknown Source)
>         at 
> org.apache.logging.log4j.spi.AbstractLogger.handleLogMessageException(AbstractLogger.java:2234)
>         at 
> org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2208)
>         at 
> org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2159)
>         at 
> org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2142)
>         at 
> org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2017)
>         at 
> org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1983)
>         at 
> org.apache.logging.log4j.spi.AbstractLogger.warn(AbstractLogger.java:2676)
>         at 
> org.apache.logging.log4j.spi.AbstractLogger.handleLogMessageException(AbstractLogger.java:2235)
> {code}
> We suspect it's an infinite loop caused by throwing an exception why another 
> exception is being handled.
> Upgrading from 2.14.0 to 2.14.1 didn't help. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to