Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThrowableProxyHelper fails if a class in logged stack trace throws java.lang.Error from initializer #3137

Closed
jaumegras opened this issue Oct 29, 2024 · 4 comments
Assignees
Labels
bug Incorrect, unexpected, or unintended behavior of existing code
Milestone

Comments

@jaumegras
Copy link

Description

When the Logger attempts to log a message with an exception stack trace, it uses the ThrowableProxyHelper class to introspect classes in the stack trace frames.

If the class sun.reflect.misc.Trampoline is in the stack trace, the introspection performed by ThrowableProxyHelper will fail causing a java.lang.Error to be thrown by the Logger call.

The sun.reflect.misc.Trampoline class is used by the sun.reflect.misc.MethodUtil class to perform reflection-based method invocations. MethodUtil is widely used by libraries to perform method invocations. I've encountered this problem when invoking methods over JMX.

Have there been any changes? The same bug LOG4J2-832 was reported and fixed for version 2.1.

Configuration

Version: 2.23.1

Operating system: Oracle Linux Server 9.4

JDK: 11.0.23 2024-04-16 LTS

Logs

org.apache.logging.log4j.core.appender.AppenderLoggingException: java.lang.Error: Trampoline must not be defined by the bootstrap classloader
at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:164)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:133)
at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:124)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:88)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:705)
at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:663)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:639)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:575)
at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:92)
at org.apache.logging.log4j.core.Logger.log(Logger.java:169)
at org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2906)
at org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2859)
at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2841)
at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2620)
at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:2567)
at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:808)
at com.xxx.xxx.xxx.xxx.clients.migration.MainKt.main(Main.kt:42)
Caused by: java.lang.Error: Trampoline must not be defined by the bootstrap classloader
at java.base/sun.reflect.misc.Trampoline.(MethodUtil.java:51)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at org.apache.logging.log4j.util.LoaderUtil.loadClass(LoaderUtil.java:207)
at org.apache.logging.log4j.core.impl.ThrowableProxyHelper.loadClass(ThrowableProxyHelper.java:213)
at org.apache.logging.log4j.core.impl.ThrowableProxyHelper.toExtendedStackTrace(ThrowableProxyHelper.java:112)
at org.apache.logging.log4j.core.impl.ThrowableProxy.(ThrowableProxy.java:144)
at org.apache.logging.log4j.core.impl.ThrowableProxy.(ThrowableProxy.java:149)
at org.apache.logging.log4j.core.impl.ThrowableProxy.(ThrowableProxy.java:118)
at org.apache.logging.log4j.core.impl.ThrowableProxy.(ThrowableProxy.java:96)
at org.apache.logging.log4j.core.impl.Log4jLogEvent.getThrownProxy(Log4jLogEvent.java:818)
at org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter.format(ExtendedThrowablePatternConverter.java:63)
at org.apache.logging.log4j.core.pattern.PatternFormatter.format(PatternFormatter.java:44)
at org.apache.logging.log4j.core.layout.PatternLayout$PatternFormatterPatternSerializer.toSerializable(PatternLayout.java:397)
at org.apache.logging.log4j.core.layout.PatternLayout.toText(PatternLayout.java:252)
at org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:238)
at org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:58)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.directEncodeEvent(AbstractOutputStreamAppender.java:227)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.tryAppend(AbstractOutputStreamAppender.java:220)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:211)
at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:160)
... 16 more

@vy vy self-assigned this Oct 29, 2024
@vy vy added bug Incorrect, unexpected, or unintended behavior of existing code and removed waiting-for-maintainer labels Oct 29, 2024
@vy
Copy link
Member

vy commented Oct 29, 2024

@jaumegras, in the upcoming 2.25.0 release, ThrowableProxy et al. will be deprecated and not used anymore. Would you mind checking against 2.25.0-SNAPSHOT (see Using snapshots page) and reporting us the outcome, please?

@vy vy added the waiting-for-user More information is needed from the user label Oct 29, 2024
@jaumegras
Copy link
Author

@vy , checking it against a 4.2.5-SNAPSHOT does not happen the problem. Could you tell me if there is a release date for this release? Thank you very much

@github-actions github-actions bot added waiting-for-maintainer and removed waiting-for-user More information is needed from the user labels Oct 31, 2024
@vy
Copy link
Member

vy commented Oct 31, 2024

@jaumegras, thanks for the confirmation. We don't have a concrete date for the 2.25.0 release, I guess it should happen in a month or two.

@vy vy closed this as completed Oct 31, 2024
@vy vy added this to the 2.25.0 milestone Oct 31, 2024
@vy
Copy link
Member

vy commented Oct 31, 2024

Fixed by #2691.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect, unexpected, or unintended behavior of existing code
Projects
None yet
Development

No branches or pull requests

2 participants