-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Deadlock due to logging inside classloaders #5950
Comments
The entire The specific Logging from the classlib level (be it either java.lang.logging, javax.management, or even java.lang.System.Logger) during a classloader is actually quite common within the JVM itself and isn't too tricky to trigger on the JVM (any of the following technology choices have been shown to trigger logging during classloading from the JVM itself: use JMX, use a URLStreamHandler, use JPMS, use a java Proxy class, use a Security manager, use a java.lang.instrumented.ClassFileTransformer). Also, if you use certain common, and popular technologies, you'll have an increased chance of triggering logging during classloading as well (OSGi, CDI, Spring, aop, etc). This is the reality of world we live in as developers. I see you have hudson/jenkins in the mix here. It also appears that you are encountering this during JVM shutdown as I see some JVM shutdown hooks. |
This seems like it might be related to (or a duplicate of) the previous Issue #1563 |
related in the way that - there is class loading going on during logging, and the class loader is logging....
I see this not only at shutdown, that stack above was just an example stack trace I had to hand. I can cause this deadlock at startup.
which is why when doing any of the above you need to be really careful about what you do or do not do,and when you do, or do not do it, especially when holding any locks, and especially when what you are interacting with is not under your direct control. In other words open calls from classloaders ( This issue was uncovered after I fixed an issue in an associated transformer (not a -- |
I think we should just remove logging from WebAppClassLoader loading methods and any methods it calls from them. |
You are not just removing logging from WebAppClassLoader, you are also removing it from anything that WebAppClassLoader uses while it's attempting to resolve / load a class or resource. |
Here's what's impacted ...
And that's just the shallow dive into what "remove logging from WebAppClassLoader" means. |
@joakime I'm saying we should remove logging from just the methods called whilst loading a class. I do not believe the list is very extensive.. so it is worth investigating how extensive because I think there is a reasonable chance of a simple change avoiding this issue entirely.... but I could be wrong. |
Signed-off-by: Joakim Erdfelt <[email protected]>
…-during-classloading Issue #5950 - remove WebAppClassLoader logging during loadClass
PR #5957 has been merged. |
Jetty version
9.4.35.v20201120
Java version
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.265-b01, mixed mode)
OS type/version
Windows 10, (but also seen on Linux)
Description
It is possible to deadlock Jetty by enabling FINEST logging.
This is becsause the
WebAppClassLoader
itslef uses logging, and also that the act of logging can itself cause class loading. Due to locking in ClassLoaders this can this can cause deadlocks.Therefore it is normal that classloaders never provide any synchronous form of logging, but Jetty's
WebAppClassLoader
does perform some logging - as follows(the classloading lock used by the
AntClassLoader
in the Jenkins project (take from the ant project) is using an overly broad lock for classloading by the looks of it, however should just increases the chance of the deadlock and not be a cause of it.An example from the Jenkins project
Whilst one could argue that formatting a
LogRecord
should be done without holding locks on the underlyingHandler
there is a reason why the JDK and other classloaders do not perform logging (and why the
-verbose:class
exists)The text was updated successfully, but these errors were encountered: