RFR: 8329013: StackOverflowError when starting Apache Tomcat with signed jar

Sean Coffey coffeys at openjdk.org
Tue Apr 2 10:29:58 UTC 2024


On Thu, 28 Mar 2024 15:55:12 GMT, Sean Coffey <coffeys at openjdk.org> wrote:

> Calling extra logging calls during initialization of Logger libraries can cause recursion leading to StackOverflowError
> This patch adds logic to the EventHelper class to detect recursion and prevent it.

Thanks for taking a look at this Jai. Without the src patch, the test should create an SOE. Have a look at the resulting jtr file[1]. jtreg complains about a timeout due to some other lock up issue. I figured that since the test shouldn't fail, then it shouldn't be an issue. Probably worth logging another issue to track that.

The `EventHelper` class can be called to log crypto events - if these events occur during logging initialization, then recursive calls can cause problems. This patch should fix up that area and block recursive calls (by returning false in the 2nd recursive call into same method)

[1]

`Java HotSpot(TM) 64-Bit Server VM warning: Potentially dangerous stack overflow in ReservedStackAccess annotated method java.util.logging.LogManager.ensureLogManagerInitialized()V [1]
java.lang.NoClassDefFoundError: Could not initialize class jdk.internal.event.EventHelper$ThreadTrackHolder
        at java.base/jdk.internal.event.EventHelper.endLookup(EventHelper.java:146)
        at java.base/jdk.internal.event.EventHelper.isLoggingSecurity(EventHelper.java:169)
        at RecursiveEventHelper.getProperty(RecursiveEventHelper.java:56)
        at java.logging/java.util.logging.LogManager.getLevelProperty(LogManager.java:2340)
        at java.logging/java.util.logging.LogManager$LoggerContext.addLocalLogger(LogManager.java:802)
        at java.logging/java.util.logging.LogManager$LoggerContext.ensureDefaultLogger(LogManager.java:752)
        at java.logging/java.util.logging.LogManager$LoggerContext.ensureInitialized(LogManager.java:660)
        at java.logging/java.util.logging.LogManager$LoggerContext.getLoggerNames(LogManager.java:852)
        at java.logging/java.util.logging.LogManager.resetLoggerContext(LogManager.java:1461)
        at java.logging/java.util.logging.LogManager.reset(LogManager.java:1451)
        at java.logging/java.util.logging.LogManager.readConfiguration(LogManager.java:1581)
        at java.logging/java.util.logging.LogManager.readConfiguration(LogManager.java:1384)
        at java.logging/java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:446)
        at java.logging/java.util.logging.LogManager$2.run(LogManager.java:395)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
        at java.logging/java.util.logging.LogManager.ensureLogManagerInitialized(LogManager.java:383)
        at java.logging/java.util.logging.LogManager.getLogManager(LogManager.java:431)
        at java.logging/sun.util.logging.internal.LoggingProviderImpl.demandJULLoggerFor(LoggingProviderImpl.java:409)
        at java.logging/sun.util.logging.internal.LoggingProviderImpl.demandLoggerFor(LoggingProviderImpl.java:438)
        at java.base/jdk.internal.logger.DefaultLoggerFinder.getLogger(DefaultLoggerFinder.java:159)
        at java.base/jdk.internal.logger.LazyLoggers.getLoggerFromFinder(LazyLoggers.java:410)
        at java.base/jdk.internal.logger.LazyLoggers.getLogger(LazyLoggers.java:437)
        at java.base/java.lang.System.getLogger(System.java:1831)
        at RecursiveEventHelper.main(RecursiveEventHelper.java:47)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
        at java.base/java.lang.Thread.run(Thread.java:1575)
Caused by: java.lang.StackOverflowError
`

-------------

PR Comment: https://git.openjdk.org/jdk/pull/18534#issuecomment-2031635027


More information about the core-libs-dev mailing list