corretto / corretto-21

GNU General Public License v2.0
66 stars 14 forks source link

java.lang.ClassCircularityError: jdk/internal/misc/VirtualThreads thrown when using virtual threads under load #65

Open pzgadzaj-equinix opened 1 month ago

pzgadzaj-equinix commented 1 month ago

Describe the bug

To Reproduce

No steps to reproduce. Happens from time to time, and only when high load is there. So i cannot provide exact steps or reproducible example. Found two tickets over internet which might be related:

Expected behavior

No exceptions

Screenshots

N/A

Platform information

Additional context

Full stacktrace: fulls_stacktrace.txt

shipilev commented 4 weeks ago

JDK-8322846 is already backported to 21.0.4 upstream, and would land in Corretto 21.0.4 release next week.

That said, java.lang.ClassCircularityError does not look like JDK-8322846. CCE implicates the class transformation code is some way. We have seen issues when agent tries to load the class that is currently under retransformation (JDK-8164165 shows the JVM throws CCE instead of more proper LinkageError in that case).

So I believe this is a bug in either OTel or AppDynamics java agent. Look around their bug-trackers for possibly related ClassCircularityError fixes.

simonis commented 3 weeks ago

I agree with @shipilev. This is most likely caused by incorrect usage of bytecode transformation in one of your instrumentation agents. Take a look at ByteBuddy issue #1666 for more details. That issue also references similar issues in the Data Dog dd-trace and the Glowroot library.

I've recently also opened JDK-8335619: Add an @apiNote to j.l.i.ClassFileTransformer to warn about recursive class loading and ClassCircularityErrors and submitted a PR for it.

AlanBateman commented 3 weeks ago

The supporting class jdk.internal.misc.VirtualThreads has been removed in the loom repo, as has jdk.internal.event.VirtualThreadPinnedEvent. This removes class loading from LockSupport.park that can happen when the first usage is in a class file transformer, which may be what is happening here. I hope to bring some of these changes into main line in advance of the object monitors work.