java代理在启动时死锁,锁定classloader和[i?

qybjjes1  于 2021-07-12  发布在  Java
关注(0)|答案(1)|浏览(400)

带有两个javaagent的应用程序,陷入僵局(在main执行之前)。
为什么有一个线程试图得到锁 [I ? 为什么会有死路一条?
jstack的死锁输出:

Found one Java-level deadlock:
=============================
"com.taobao.diamond.client.Worker.longPullingdefault":
  waiting to lock monitor 0x00007fb6341d0ec8 (object 0x000000073e8efe20, a [I),
  which is held by "oneagent plugin Bsnt-agent start"
"oneagent plugin Bsnt-agent start":
  waiting to lock monitor 0x00007fb6940038d8 (object 0x0000000766224ec8, a com.bilibili.ntib.agent.starter.SandboxClassLoader),
  which is held by "oneagent plugin msha-java-agent start"
"oneagent plugin msha-java-agent start":
  waiting to lock monitor 0x00007fb6341d0ec8 (object 0x000000073e8efe20, a [I),
  which is held by "oneagent plugin Bsnt-agent start"

Java stack information for the threads listed above:
===================================================
"com.taobao.diamond.client.Worker.longPullingdefault":
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.structure.ClassStructureImplByAsm.<init>(ClassStructureImplByAsm.java:400)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.structure.ClassStructureFactory.createClassStructure(ClassStructureFactory.java:57)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.SandboxClassFileTransformer.getClassStructure(SandboxClassFileTransformer.java:64)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.SandboxClassFileTransformer._transform(SandboxClassFileTransformer.java:117)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.SandboxClassFileTransformer.transform(SandboxClassFileTransformer.java:84)
    at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    - locked <0x00000007435e1620> (a java.lang.Object)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.taobao.diamond.client.impl.CacheData.safeNotifyListener(CacheData.java:145)
    at com.taobao.diamond.client.impl.CacheData.checkListenerMd5(CacheData.java:136)
    at com.taobao.diamond.client.impl.ClientWorker$LongPullingRunnable.run(ClientWorker.java:451)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
"oneagent plugin Bsnt-agent start":
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.structure.ClassStructureImplByAsm.<init>(ClassStructureImplByAsm.java:400)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.structure.ClassStructureFactory.createClassStructure(ClassStructureFactory.java:57)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.SandboxClassFileTransformer.getClassStructure(SandboxClassFileTransformer.java:64)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.SandboxClassFileTransformer._transform(SandboxClassFileTransformer.java:117)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.SandboxClassFileTransformer.transform(SandboxClassFileTransformer.java:84)
    at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    - locked <0x000000073e463248> (a com.navercorp.pinpoint.common.plugin.PluginLoaderClassLoader)
    at com.navercorp.pinpoint.common.plugin.PluginLoaderClassLoader.loadClass(PluginLoaderClassLoader.java:45)
    - locked <0x000000073e463248> (a com.navercorp.pinpoint.common.plugin.PluginLoaderClassLoader)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.navercorp.pinpoint.plugin.jdbc.ppas.PPASPlugin.<init>(PPASPlugin.java:29)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at com.navercorp.pinpoint.common.plugin.PluginLoader.load(PluginLoader.java:66)
    at com.navercorp.pinpoint.common.plugin.PluginLoader.load(PluginLoader.java:47)
    at com.navercorp.pinpoint.profiler.plugin.ProfilerPluginLoader.load(ProfilerPluginLoader.java:84)
    at com.navercorp.pinpoint.profiler.plugin.DefaultPluginContextLoadResult.load(DefaultPluginContextLoadResult.java:80)
    at com.navercorp.pinpoint.profiler.plugin.DefaultPluginContextLoadResult.<init>(DefaultPluginContextLoadResult.java:70)
    at com.navercorp.pinpoint.profiler.context.provider.PluginContextLoadResultProvider.get(PluginContextLoadResultProvider.java:68)
    at com.navercorp.pinpoint.profiler.context.provider.PluginContextLoadResultProvider.get(PluginContextLoadResultProvider.java:34)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1019)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1015)
    at com.navercorp.pinpoint.profiler.context.provider.ApplicationServerTypeProvider.get(ApplicationServerTypeProvider.java:62)
    at com.navercorp.pinpoint.profiler.context.provider.ApplicationServerTypeProvider.get(ApplicationServerTypeProvider.java:36)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
    at com.google.inject.Guice.createInjector(Guice.java:99)
    at com.google.inject.Guice.createInjector(Guice.java:84)
    at com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext.<init>(DefaultApplicationContext.java:145)
    at com.navercorp.pinpoint.profiler.DefaultAgent.newApplicationContext(DefaultAgent.java:127)
    at com.navercorp.pinpoint.profiler.DefaultAgent.<init>(DefaultAgent.java:107)
    at com.navercorp.pinpoint.profiler.DefaultAgent.<init>(DefaultAgent.java:70)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.navercorp.pinpoint.bootstrap.AgentClassLoader$2.call(AgentClassLoader.java:78)
    at com.navercorp.pinpoint.bootstrap.ContextClassLoaderExecuteTemplate.execute(ContextClassLoaderExecuteTemplate.java:42)
    at com.navercorp.pinpoint.bootstrap.AgentClassLoader.boot(AgentClassLoader.java:73)
    at com.navercorp.pinpoint.bootstrap.PinpointStarter.run(PinpointStarter.java:111)
    at com.navercorp.pinpoint.bootstrap.PinpointBootStrap.bootstrap(PinpointBootStrap.java:255)
    at com.navercorp.pinpoint.bootstrap.PinpointBootStrap.premain(PinpointBootStrap.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.alibaba.oneagent.plugin.TraditionalPlugin.start(TraditionalPlugin.java:109)
    at com.alibaba.oneagent.plugin.PluginManagerImpl.startOnePlugin(PluginManagerImpl.java:302)
    at com.alibaba.oneagent.plugin.PluginManagerImpl.access$200(PluginManagerImpl.java:31)
    at com.alibaba.oneagent.plugin.PluginManagerImpl$2.run(PluginManagerImpl.java:333)
    at java.lang.Thread.run(Thread.java:748)
"oneagent plugin msha-java-agent start":
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.structure.ClassStructureImplByAsm.<init>(ClassStructureImplByAsm.java:400)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.structure.ClassStructureFactory.createClassStructure(ClassStructureFactory.java:57)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.SandboxClassFileTransformer.getClassStructure(SandboxClassFileTransformer.java:64)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.SandboxClassFileTransformer._transform(SandboxClassFileTransformer.java:117)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.SandboxClassFileTransformer.transform(SandboxClassFileTransformer.java:84)
    at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    - locked <0x000000073e0a65f8> (a java.lang.Object)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
    - locked <0x0000000766224ec8> (a com.bilibili.ntib.agent.starter.SandboxClassLoader)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.classloader.RoutingURLClassLoader$1.loadClass(RoutingURLClassLoader.java:74)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.classloader.ClassLoadingLock.loadingInLock(ClassLoadingLock.java:55)
    - locked <0x000000073e0a5610> (a java.lang.Object)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.classloader.RoutingURLClassLoader.loadClass(RoutingURLClassLoader.java:63)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.bilibili.ntib.agent.sandbox.module.SandboxFilter.doClassFilter(SandboxFilter.java:97)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.ExtFilterMatcher.matchingClassStructure(ExtFilterMatcher.java:59)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.ExtFilterMatcher._matching(ExtFilterMatcher.java:113)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.ExtFilterMatcher.matching(ExtFilterMatcher.java:79)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.GroupMatcher$And.matching(GroupMatcher.java:52)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreLoadedClassDataSource.find(DefaultCoreLoadedClassDataSource.java:106)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreLoadedClassDataSource.findForReTransform(DefaultCoreLoadedClassDataSource.java:73)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultModuleEventWatcher.watch(DefaultModuleEventWatcher.java:186)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultModuleEventWatcher.watch(DefaultModuleEventWatcher.java:158)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultModuleEventWatcher.watch(DefaultModuleEventWatcher.java:150)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.SandboxProtector$2.invoke(SandboxProtector.java:91)
    at com.sun.proxy.$Proxy56.watch(Unknown Source)
    at com.bilibili.ntib.agent.sandbox.module.MshaSandboxModule.registerAspectPlugins(MshaSandboxModule.java:123)
    at com.bilibili.ntib.agent.sandbox.module.MshaSandboxModule.loadAspectPlugins(MshaSandboxModule.java:55)
    at com.bilibili.ntib.agent.sandbox.module.MshaSandboxModule.onActive(MshaSandboxModule.java:44)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager.callAndFireModuleLifeCycle(DefaultCoreModuleManager.java:120)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager.active(DefaultCoreModuleManager.java:433)
    - locked <0x0000000737424d18> (a com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager.markActiveOnLoadIfNecessary(DefaultCoreModuleManager.java:338)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager.load(DefaultCoreModuleManager.java:193)
    - locked <0x0000000737424d18> (a com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager.access$300(DefaultCoreModuleManager.java:38)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager$InnerModuleLoadCallback.onLoad(DefaultCoreModuleManager.java:580)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.ModuleJarLoader.loadingModules(ModuleJarLoader.java:93)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.ModuleJarLoader.load(ModuleJarLoader.java:129)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.ModuleLibLoader.load(ModuleLibLoader.java:77)
    at com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager.reset(DefaultCoreModuleManager.java:607)
    - locked <0x0000000737424d18> (a com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.manager.impl.DefaultCoreModuleManager)
    at com.bilibili.ntib.agent.boot.sandbox.AgentModuleManager.initManager(AgentModuleManager.java:120)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.bilibili.ntib.agent.starter.initializer.SandboxAgentInitializer.init(SandboxAgentInitializer.java:18)
    at com.bilibili.ntib.agent.starter.AgentLauncher.launch(AgentLauncher.java:53)
    at com.bilibili.ntib.agent.starter.AgentMain.premain(AgentMain.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.alibaba.oneagent.plugin.TraditionalPlugin.start(TraditionalPlugin.java:109)
    at com.alibaba.oneagent.plugin.PluginManagerImpl.startOnePlugin(PluginManagerImpl.java:302)
    at com.alibaba.oneagent.plugin.PluginManagerImpl.access$200(PluginManagerImpl.java:31)
    at com.alibaba.oneagent.plugin.PluginManagerImpl$2.run(PluginManagerImpl.java:333)
    at java.lang.Thread.run(Thread.java:748)

Found 1 deadlock.

全部输出 jstack : https://pastebin.com/z1frqepx
全部输出 jstack -m : https://pastebin.com/t6awe6k7
一些实现的源代码:
com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.util.matcher.structure.classstructureimplbyasm
com.bilibili.ntib.third.com.alibaba.jvm.sandbox.core.classloader.routingurlclassloader
com.navercorp.pinpoint.common.plugin.pluginloaderclassloader插件
com.bilibili.ntib.agent.starter.sandboxclassloader:

class SandboxClassLoader extends URLClassLoader {

    SandboxClassLoader(final String namespace) throws Throwable {
        super(getServiceJar());
    }

    private static URL[] getServiceJar() throws IOException {
        // ...
        return urls;
    }

    @Override
    public URL getResource(String name) {
        URL url = super.getResource(name);
        return url;
    }

    @Override
    public Enumeration<URL> getResources(String name) throws IOException {
        Enumeration<URL> urls = super.getResources(name);
        return urls;
    }
}

com.alibaba.one代理
java版本: Java HotSpot(TM) 64-Bit Server VM; 1.8.0_172; 25.172-b11; mixed mode

yshpjwxd

yshpjwxd1#

在看 jstack 输出,我们看到以下内容:
的调用堆栈 com.taobao.diamond.client.Worker.longPullingdefault : ClassStructureImplByAsm.<init>(ClassStructureImplByAsm.java:400) :的 <init> 告诉您在执行构造函数或以其他方式初始化正在构造的对象的示例时发生的情况,即在为字段指定默认值时。这里的情况是后者,因为第400行为 ClassStructureImplByAsm.annotationTypeClassStructuresLazyGet 类型 LazyGet . 更确切地说,一个匿名者的例子 LazyGet<List<ClassStructure>> 正在创建和分配子类。
在第一个调用堆栈中查找,我们看到 CacheData.safeNotifyListener 试着打电话 ClassLoader.loadClass . 在jdk源代码中该方法的开头 synchronized (getClassLoadingLock(name)) 而且在 getClassLoadingLock 您可以看到,默认情况下(不支持并行的类加载器),它只是在 this ,即在classloader示例上。
的调用堆栈 oneagent plugin Bsnt-agent start :
同样,调用堆栈的顶部是 ClassStructureImplByAsm.<init>(ClassStructureImplByAsm.java:400) ,就像以前一样。
再一次, ClassLoader.loadClass 在类加载器上触发并同步,这次由 PluginLoaderClassLoader.loadClass(PluginLoaderClassLoader.java:45) .
的调用堆栈 oneagent plugin msha-java-agent start :
同样,调用堆栈的顶部是 ClassStructureImplByAsm.<init>(ClassStructureImplByAsm.java:400) ,就像以前一样。
再一次, ClassLoader.loadClass 在类加载器上触发和同步,这次由 SandboxFilter.doClassFilter(SandboxFilter.java:97) ,再往上一层 RoutingURLClassLoader$1.loadClass(RoutingURLClassLoader.java:74) . 一 SandboxClassLoader 似乎也牵涉其中。
我不确定,但看起来死锁似乎发生在 ClassLoader 基类,而三个独立的线程正试图同时在其上同步。
也许推迟分配会有帮助 ClassStructureImplByAsm.annotationTypeClassStructuresLazyGet 在lazy getter方法内部,即当第一次需要成员时 null ,getter创建匿名子类示例。否则它只返回已经分配的成员。我不知道你是不是一个 ClassStructureImplByAsm 并且可以更改它,但即使没有,您至少可以在为上游项目创建pull请求之前,派生它并在本地测试修改。
对不起,我不能说更具体的,因为我不能编译和运行 jstack 为了重现你的问题。一个复制者样本项目,即mcve,会更好。

相关问题