[ 
https://issues.apache.org/jira/browse/LOG4J2-1634?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rod Burgett updated LOG4J2-1634:
--------------------------------
    Attachment: ReproLoggerConfigBug.java

Hi Gary,
I've attached the repro class.  It gets the same results using v2.6.2 and the 
v2.7 jar I downloaded this morning.
Rod

> Root LoggerConfig is corrupted leading to stack overflow
> --------------------------------------------------------
>
>                 Key: LOG4J2-1634
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1634
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.6.2
>            Reporter: Rod Burgett
>         Attachments: ReproLoggerConfigBug.java
>
>
> The simple repro code below demonstrates the corruption of the LoggerConfig 
> instance for root logger.  Executing the main leads to unstopped recursion, 
> leading to stack overflow.  The recursion includes three method calls, shown 
> in this stack trace fragment:
>         at 
> org.apache.logging.log4j.core.config.LoggerConfig.logParent(LoggerConfig.java:381)
>         at 
> org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:376)
>         at 
> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:359)
>         at 
> org.apache.logging.log4j.core.config.LoggerConfig.logParent(LoggerConfig.java:381)
>         at 
> org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:376)
>         at 
> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:359)
>         at 
> org.apache.logging.log4j.core.config.LoggerConfig.logParent(LoggerConfig.java:381)
>         at 
> org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:376)
>         at 
> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:359)
> The basic problem is that 'logParent' becomes no-op (ends recursion) if 
> additivity is off or if logger config's parent is null, otherwise recusrion 
> continues.
> In the repro case, the root logger config points to itself as parent.
> I expect that when adding a logger to Configuration, the LoggerConfig should 
> be specific to the named logger.  So, the stack overflow could be avoided if 
> Configuration.addLogger checked that the LoggerConfig's name matched the 
> input logger name.
> Repro code:
>     String loggerName = "new.logger.name";
>     LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
>     Configuration config = ctx.getConfiguration();
>     LoggerConfig logCfg = config.getLoggerConfig(loggerName);
>     config.addLogger(loggerName, logCfg);
>     ctx.updateLoggers();
>     LogManager.getLogger(loggerName).error("...by: "+loggerName+"....");



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org

Reply via email to