2

最近、非常に奇妙な状態のマルチスレッド デッドロックに遭遇しました。スタック トレースのどのメソッドでも実際にロックを要求していないスレッドがロックを保持しているように見えます。必要なスタック トレースは次のとおりです。

Found one Java-level deadlock:
=============================
"pool-1-thread-2":
  waiting to lock monitor 0x000000000751fc20 (object 0x00000000f55e2960, a de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager$ExtensionLoader),
  which is held by "pool-1-thread-1"
"pool-1-thread-1":
  waiting to lock monitor 0x000000000052ba78 (object 0x00000000f55dfc98, a de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager),
  which is held by "pool-1-thread-2"

Java stack information for the threads listed above:
===================================================
"pool-1-thread-2":
    at java.lang.ClassLoader.checkCerts(ClassLoader.java:782)
    - waiting to lock <0x00000000f55e2960> (a de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager$ExtensionLoader)
    at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:625)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager$ExtensionLoader.loadClassDirect(CraftElevatorsExtensionManager.java:149)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager$ExtensionLoader.access$4(CraftElevatorsExtensionManager.java:147)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager.findClass(CraftElevatorsExtensionManager.java:85)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    - locked <0x00000000f55dfc98> (a de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
    - locked <0x00000000f55dfc38> (a de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager$ExtensionLoader)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager$ExtensionLoader.loadClass(CraftElevatorsExtensionManager.java:231)
    - locked <0x00000000f55dfc98> (a de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2436)
    at java.lang.Class.privateGetPublicMethods(Class.java:2556)
    at java.lang.Class.getMethods(Class.java:1412)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.elevator.CraftElevatorEventManager.register(CraftElevatorEventManager.java:147)
    at de.ntcomputer.minecraft.elevators2.doorsext.implementation.elevator.CraftElevatorDoorsExtension.onEnable(CraftElevatorDoorsExtension.java:61)
    - locked <0x00000000f55b8e58> (a de.ntcomputer.minecraft.elevators2.doorsext.implementation.elevator.CraftElevatorDoorsExtension)
    at de.ntcomputer.minecraft.elevators2.plugin.api.elevator.extension.CraftElevatorExtension.initialize(CraftElevatorExtension.java:16)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.elevator.CraftElevator.initialize(CraftElevator.java:72)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storage.CraftElevatorLoader.loadSync(CraftElevatorLoader.java:48)
    - locked <0x00000000f55b8f08> (a de.ntcomputer.minecraft.elevators2.plugin.implementation.storage.CraftElevatorLoader)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storage.CraftElevatorLoader.access$0(CraftElevatorLoader.java:39)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storage.CraftElevatorLoader$1.run(CraftElevatorLoader.java:64)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.scheduler.CraftElevatorTask.run(CraftElevatorTask.java:53)
    at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftTask.run(CraftTask.java:53)
    at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
"pool-1-thread-1":
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager$ExtensionLoader.loadClass(CraftElevatorsExtensionManager.java:231)
    - waiting to lock <0x00000000f55dfc98> (a de.ntcomputer.minecraft.elevators2.plugin.implementation.extension.CraftElevatorsExtensionManager)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at de.ntcomputer.minecraft.elevators2.extfloors.implementation.elevator.CraftInteractiveElevatorFloorsExtension.deserializeFloor(CraftInteractiveElevatorFloorsExtension.java:116)
    at de.ntcomputer.minecraft.elevators2.extfloors.implementation.elevator.CraftElevatorFloorsExtension$2.deserialize(CraftElevatorFloorsExtension.java:84)
    at de.ntcomputer.minecraft.elevators2.extfloors.implementation.elevator.CraftElevatorFloorsExtension$2.deserialize(CraftElevatorFloorsExtension.java:1)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storagefile.CraftStorageSectionReader.deserializeObject(CraftStorageSectionReader.java:151)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storagefile.CraftStorageSectionReader.deserializeCoreObject(CraftStorageSectionReader.java:199)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storagefile.CraftStorageSectionReader.inflateKeyMapEmpty(CraftStorageSectionReader.java:530)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storagefile.CraftStorageSectionReader.inflateMapValuesEmpty(CraftStorageSectionReader.java:996)
    at de.ntcomputer.minecraft.elevators2.extfloors.implementation.elevator.CraftElevatorFloorsExtension.onEnable(CraftElevatorFloorsExtension.java:76)
    at de.ntcomputer.minecraft.elevators2.extfloors.implementation.elevator.CraftInteractiveElevatorFloorsExtension.onEnable(CraftInteractiveElevatorFloorsExtension.java:70)
    at de.ntcomputer.minecraft.elevators2.plugin.api.elevator.extension.CraftElevatorExtension.initialize(CraftElevatorExtension.java:16)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.elevator.CraftElevator.initialize(CraftElevator.java:72)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storage.CraftElevatorLoader.loadSync(CraftElevatorLoader.java:48)
    - locked <0x00000000f5601ac8> (a de.ntcomputer.minecraft.elevators2.plugin.implementation.storage.CraftElevatorLoader)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storage.CraftElevatorLoader.access$0(CraftElevatorLoader.java:39)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.storage.CraftElevatorLoader$1.run(CraftElevatorLoader.java:64)
    at de.ntcomputer.minecraft.elevators2.plugin.implementation.scheduler.CraftElevatorTask.run(CraftElevatorTask.java:53)
    at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftTask.run(CraftTask.java:53)
    at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)

Found 1 deadlock.

ご覧のとおり、スレッド 2 は明らかにスレッド 1 によって保持されている <0x00000000f55e2960> をロックしようとしますが、スレッド 1 はどの方法でも <0x00000000f55e2960> をロックしませんでした! これはどのように可能ですか?

前もってありがとう、DevCybran

編集:使用されたクラスローダーコードを追加:

public class CraftElevatorsExtensionManager extends ClassLoader implements FilenameFilter, ElevatorsExtensionManager {
    private Map<String,ExtensionLoader> loaders = null;

    ...


    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        for(ExtensionLoader loader: loaders.values()) {
            try {
                return loader.loadClassDirect(name); // line 85
            } catch(ClassNotFoundException e) { }
        }
        throw new ClassNotFoundException();
    }

    ...

    private class ExtensionLoader extends URLClassLoader {

        ...

        private Class<?> loadClassDirect(String name) throws ClassNotFoundException {
            Class<?> loadedClass = this.findLoadedClass(name);
            if(loadedClass==null) return this.findClass(name); // line 149
            return loadedClass;
        }

        ...

        @Override
        protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
            // synchronized parent container first  - should prevent deadlocks
            synchronized(CraftElevatorsExtensionManager.this) {
                return super.loadClass(name, resolve); // line 231
            }
        }

    }

}

Java 6 u45 を使用。

4

1 に答える 1

0

ここでの私の推測では、3way デッドロックがあると思います。ひょっとして、アプリ内に他のスレッドはありませんか?
Pool-1-Thread-1 Hold 2 Locks:0x000000F55DFC98および0x000000P5601AC8が表示され
ます。Pool-1-Thread-2は0x00000000F55E2960、0X000000F55DFC98を保持し
ています。 ?
または似たようなもの。

于 2013-10-27T03:20:18.293 に答える