Random Crashing.

Discussion in 'Plugin Development' started by Fiddy_percent, May 27, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Fiddy_percent

    Code:
    java.util.ConcurrentModificationException
        at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
        at java.util.HashMap$KeyIterator.next(Unknown Source)
        at net.minecraft.server.v1_7_R1.EntityTracker.updatePlayers(EntityTracker.java:152)
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:646)
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250)
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545)
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457)
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617)
    
    I'm almost 100% sure its my plugin thats doing this the alternative is we have a lot of custom block spawning mobs (mobs with names and armor ect)

    Not sure what might be triggering this could this be it?

    Code:java
    1.  
    2. List<Entity> witnesses = event.getEntity().getNearbyEntities(10, 10, 10);
    3.  
    4. for(Entity y : witnesses){
    5. if(y instanceof HumanEntity){
    6. String name = ((HumanEntity) y).getName();
    7. witness.add(name);
    8. }
    9. }
    10. if(witness.isEmpty()){
    11. witness.add("none");
    12. }
    13.  
     
  2. Offline

    Obnoxious_Ninja

    You seem to have two variables you're trying to use as one.
    Code:java
    1.  
    2. List<Entity> witnesses = event.getEntity().getNearbyEntities(10, 10, 10);
    3.  

    then:
    Code:java
    1.  
    2. witness.add(name);
    3. if(witness.isEmpty()){
    4. witness.add("none");
    5.  


    Either change witnesses to witness, or vice versa.

    It should look like this:
    Code:java
    1. List<Entity> witnesses = event.getEntity().getNearbyEntities(10, 10, 10);
    2. for(Entity y : witnesses){
    3. if(y instanceof HumanEntity){
    4. String name = ((HumanEntity) y).getName();
    5. witnesses.add(name);
    6. }
    7. }
    8. if(witnesses.isEmpty()){
    9. witnesses.add("none");
    10. }
     
  3. Offline

    Fiddy_percent

    @Obnoxious_Ninja


    Not sure if I'm following correctly? because they are both different Witnesses is the Entity list and Witness are the string names for the Players and if there arn't any players then Its suppose to say none.
     
  4. Offline

    Obnoxious_Ninja

    Right. You're going through every element of the list and calling it "y". Then, if y is a player, you add their name to the list (still called "witnesses"). If the list is empty, you put something in it saying "none". Witnesses is a list, not a string, and witness doesn't even exist. Is there a variable declaration that you just didn't include?
     
  5. Offline

    Fiddy_percent

    Ah sorry bout that

    Code:java
    1. ArrayList<String> witness = new ArrayList<String>();


    is up above all that its the string list.


    But im just trying to figure out what that crashing bug could be this bit of code is the only thing im going by so I figure it must be some kind of for loop or Iterator on my end
    at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
    at java.util.HashMap$KeyIterator.next(Unknown Source)

    net.minecraft.server.v1_7_R1.EntityTracker.updatePlayers(EntityTracker.java:152)
     
  6. Offline

    Obnoxious_Ninja

    Hmmm. I don't know exactly. You might want to check out this or this. The errors seem to be very similar.
     
  7. Offline

    JaguarJo

    Moved thread to a more appropriate section.
     
    Garris0n likes this.
  8. Offline

    Garris0n

    What? The code you "suggested" actually causes a ConcurrentModificationException. In addition, it doesn't make any sense. Please stop spoonfeeding people bad code. Spoonfeeding is bad enough, but you are giving people code that causes problems as well as giving them bad habits.

    @OP
    1. Revert any changes you've made due to whatever's been posted on this thread.
    2. Post the full stack trace and the full class(es) involved.
     
  9. Offline

    Fiddy_percent


    Code:
    Time: 5/27/14 7:44 PM
    Description: Exception in server tick loop
     
    java.util.ConcurrentModificationException
        at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
        at java.util.HashMap$KeyIterator.next(Unknown Source)
        at net.minecraft.server.v1_7_R1.EntityTracker.updatePlayers(EntityTracker.java:152)
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:646)
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250)
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545)
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457)
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617)
     
     
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
     
    -- System Details --
    Details:
        Minecraft Version: 1.7.2
        Operating System: Linux (amd64) version 2.6.18-371.1.2.el5
        Java Version: 1.7.0_51, Oracle Corporation
        Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
        Memory: 1837533896 bytes (1752 MB) / 2077753344 bytes (1981 MB) up to 2077753344 bytes (1981 MB)
        JVM Flags: 10 total; -Xms2048M -Xmx2048M -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+DisableExplicitGC -XX:ErrorFile=/dev/null -XX:UseSSE=3
        AABB Pool Size: 7165 (401240 bytes; 0 MB) allocated, 6815 (381640 bytes; 0 MB) used
        IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
        CraftBukkit Information:
      Running: CraftBukkit version git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks (MC: 1.7.2) (Implementing API version 1.7.2-R0.4-SNAPSHOT) true
      Plugins: { RegenBlock vBeta 5.7 net.dmg2.RegenBlock.RegenBlock [], WorldEdit v5.5.9-SNAPSHOT:3000-ab0d170,master com.sk89q.worldedit.bukkit.WorldEditPlugin [], FiddyCraft v1.6 io.github.FiddyPercent.fiddycraft.FiddyCraft [], WorldGuard v5.9 com.sk89q.worldguard.bukkit.WorldGuardPlugin [],}
      Warnings: DEFAULT
      Threads: { WAITING Chunk I/O Executor Thread-1: [sun.misc.Unsafe.park(Native Method), java.util.concurrent.locks.LockSupport.park(Unknown Source), java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source), java.util.concurrent.LinkedBlockingQueue.take(Unknown Source), java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source), java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source), java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source), java.lang.Thread.run(Unknown Source)], RUNNABLE Thread-8: [net.minecraft.server.v1_7_R1.StructureGenerator.a(SourceFile:40), net.minecraft.server.v1_7_R1.WorldGenBase.a(SourceFile:30), net.minecraft.server.v1_7_R1.ChunkProviderGenerate.recreateStructures(SourceFile:504), org.bukkit.craftbukkit.v1_7_R1.generator.NormalChunkGenerator.recreateStructures(NormalChunkGenerator.java:73), org.bukkit.craftbukkit.v1_7_R1.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:43), org.bukkit.craftbukkit.v1_7_R1.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:13), org.bukkit.craftbukkit.v1_7_R1.util.AsynchronousExecutor.skipQueue(AsynchronousExecutor.java:337), org.bukkit.craftbukkit.v1_7_R1.util.AsynchronousExecutor.getSkipQueue(AsynchronousExecutor.java:295), org.bukkit.craftbukkit.v1_7_R1.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:16), net.minecraft.server.v1_7_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:107), net.minecraft.server.v1_7_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:89), org.bukkit.craftbukkit.v1_7_R1.CraftWorld.getChunkAt(CraftWorld.java:118), org.bukkit.craftbukkit.v1_7_R1.CraftWorld.getBlockAt(CraftWorld.java:82), net.dmg2.RegenBlock.RegenBlockQueue.readyForRegen(RegenBlockQueue.java:211), net.dmg2.RegenBlock.RegenBlockQueue.checkQueue(RegenBlockQueue.java:171), net.dmg2.RegenBlock.RegenBlockQueue.run(RegenBlockQueue.java:38), java.lang.Thread.run(Unknown Source)], WAITING Thread-5: [sun.misc.Unsafe.park(Native Method), java.util.concurrent.locks.LockSupport.park(Unknown Source), java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source), java.util.concurrent.LinkedBlockingQueue.take(Unknown Source), net.minecraft.util.com.mojang.util.QueueLogAppender.getNextLogEvent(QueueLogAppender.java:73), org.bukkit.craftbukkit.v1_7_R1.util.TerminalConsoleWriterThread.run(TerminalConsoleWriterThread.java:25), java.lang.Thread.run(Unknown Source)], RUNNABLE Server console handler: [java.io.FileInputStream.readBytes(Native Method), java.io.FileInputStream.read(Unknown Source), java.io.BufferedInputStream.fill(Unknown Source), java.io.BufferedInputStream.read(Unknown Source), java.io.FilterInputStream.read(Unknown Source), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader$1.read(ConsoleReader.java:167), org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:267), org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:204), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readCharacter(ConsoleReader.java:995), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLineSimple(ConsoleReader.java:1506), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLine(ConsoleReader.java:1153), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLine(ConsoleReader.java:1117), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLine(ConsoleReader.java:1105), net.minecraft.server.v1_7_R1.ThreadCommandReader.run(ThreadCommandReader.java:34)], TIMED_WAITING File IO Thread: [java.lang.Thread.sleep(Native Method), net.minecraft.server.v1_7_R1.FileIOThread.b(SourceFile:44), net.minecraft.server.v1_7_R1.FileIOThread.run(SourceFile:23), java.lang.Thread.run(Unknown Source)], RUNNABLE Netty IO #1: [sun.nio.ch.EPollArrayWrapper.epollWait(Native Method), sun.nio.ch.EPollArrayWrapper.poll(Unknown Source), sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source), sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source), sun.nio.ch.SelectorImpl.select(Unknown Source), net.minecraft.util.io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:591), net.minecraft.util.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:301), net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101), java.lang.Thread.run(Unknown Source)], RUNNABLE Netty IO #6: [sun.nio.ch.EPollArrayWrapper.epollWait(Native Method), sun.nio.ch.EPollArrayWrapper.poll(Unknown Source), sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source), sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source), sun.nio.ch.SelectorImpl.select(Unknown Source), net.minecraft.util.io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:591), net.minecraft.util.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:301), net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101), java.lang.Thread.run(Unknown Source)], TIMED_WAITING pool-3-thread-1: [sun.misc.Unsafe.park(Native Method), java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source), java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(Unknown Source), java.util.concurrent.SynchronousQueue$TransferStack.transfer(Unknown Source), java.util.concurrent.SynchronousQueue.poll(Unknown Source), java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source), java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source), java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source), java.lang.Thread.run(Unknown Source)], RUNNABLE Signal Dispatcher: [], TIMED_WAITING Snooper Timer: [java.lang.Object.wait(Native Method), java.util.TimerThread.mainLoop(Unknown Source), java.util.TimerThread.run(Unknown Source)], RUNNABLE Netty IO #5: [sun.nio.ch.EPollArrayWrapper.epollWait(Native Method), sun.nio.ch.EPollArrayWrapper.poll(Unknown Source), sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source), sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source), sun.nio.ch.SelectorImpl.select(Unknown Source), net.minecraft.util.io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:591), net.minecraft.util.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:301), net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101), java.lang.Thread.run(Unknown Source)], WAITING Finalizer: [java.lang.Object.wait(Native Method), java.lang.ref.ReferenceQueue.remove(Unknown Source), java.lang.ref.ReferenceQueue.remove(Unknown Source), java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)], WAITING Reference Handler: [java.lang.Object.wait(Native Method), java.lang.Object.wait(Object.java:503), java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)], TIMED_WAITING Server Infinisleeper: [java.lang.Thread.sleep(Native Method), net.minecraft.server.v1_7_R1.ThreadSleepForever.run(SourceFile:62)], RUNNABLE Server thread: [java.lang.Thread.dumpThreads(Native Method), java.lang.Thread.getAllStackTraces(Unknown Source), org.bukkit.craftbukkit.v1_7_R1.CraftCrashReport.call(CraftCrashReport.java:28), net.minecraft.server.v1_7_R1.CrashReportSystemDetails.a(SourceFile:74), net.minecraft.server.v1_7_R1.CrashReport.h(CrashReport.java:45), net.minecraft.server.v1_7_R1.CrashReport.<init>(CrashReport.java:33), net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:474), net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617)], RUNNABLE Netty IO #2: [sun.nio.ch.EPollArrayWrapper.epollWait(Native Method), sun.nio.ch.EPollArrayWrapper.poll(Unknown Source), sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source), sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source), sun.nio.ch.SelectorImpl.select(Unknown Source), net.minecraft.util.io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:591), net.minecraft.util.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:301), net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101), java.lang.Thread.run(Unknown Source)], RUNNABLE Netty IO #3: [sun.nio.ch.EPollArrayWrapper.epollWait(Native Method), sun.nio.ch.EPollArrayWrapper.poll(Unknown Source), sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source), sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source), sun.nio.ch.SelectorImpl.select(Unknown Source), net.minecraft.util.io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:591), net.minecraft.util.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:301), net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101), java.lang.Thread.run(Unknown Source)], RUNNABLE DestroyJavaVM: [], RUNNABLE Netty IO #0: [sun.nio.ch.EPollArrayWrapper.epollWait(Native Method), sun.nio.ch.EPollArrayWrapper.poll(Unknown Source), sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source), sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source), sun.nio.ch.SelectorImpl.select(Unknown Source), net.minecraft.util.io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:591), net.minecraft.util.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:301), net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101), java.lang.Thread.run(Unknown Source)], RUNNABLE Netty IO #4: [sun.nio.ch.EPollArrayWrapper.epollWait(Native Method), sun.nio.ch.EPollArrayWrapper.poll(Unknown Source), sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source), sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source), sun.nio.ch.SelectorImpl.select(Unknown Source), net.minecraft.util.io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:591), net.minecraft.util.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:301), net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101), java.lang.Thread.run(Unknown Source)],}
      Recent tasks from 3886-3916{WorldEdit:com.sk89q.worldedit.bukkit.SessionTimer@3869,}
        Profiler Position: N/A (disabled)
        Vec3 Pool Size: ~~ERROR~~ NullPointerException: null
        Player Count: 1 / 20; [EntityPlayer['Fiddy_percent'/1219, l='world', x=-1458.20, y=7.04, z=-171.05](Fiddy_percent at -1458.1965255290909,7.036077565807467,-171.05353981108107)]
        Is Modded: Definitely; Server brand changed to 'CraftBukkit'
        Type: Dedicated Server (map_server.txt)

    I'm not so sure its my code anymore however >_>but the crash is so random its hard to pin down
     
  10. Offline

    Garris0n

    Well, does it happen when your plugin is not on the server?

    Do some troubleshooting.
     
  11. Offline

    Fiddy_percent

    I have been ... for hours with worldguard and edit it seemed fine. I added my plugin seemed fine added 2 other was great then the last one caused it took it away... it still happens... so went back down the list... Not knowing the trigger is killer because it can take hours for the crash to happen.

    Garris0n

    Code:java
    1. Iterator<Integer> i = spawnBlocksId.keySet().iterator();
    2. int totalChance = 0;
    3. while (i.hasNext()) { totalChance += spawnBlocksId.get(i.next()); }
    4.  
    5. if (totalChance == 0) return;
    6.  
    7. int roll = rnd.nextInt(totalChance);
    8.  
    9. int typeId = 1;
    10. i = spawnBlocksId.keySet().iterator();
    11. totalChance = 0;
    12.  
    13. while (i.hasNext()) {
    14. int blockId = i.next();
    15. int blockIdChance = spawnBlocksId.get(blockId);
    16. totalChance += blockIdChance;
    17. if (roll <= totalChance && roll >= totalChance - blockIdChance) {
    18. typeId = blockId;
    19. break;
    20. }
    21. }
    22.  
    23. material = Material.getMaterial(typeId);
    24. data = 0;
    25. }
    26.  
    27. }


    Would this cause the issue its from another plugin?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  12. Offline

    chingo247

    Code:
    List<Entity> witnesses = event.getEntity().getNearbyEntities(10, 10, 10);
    for(Entity y : witnesses){
    ...
      witnesses.add(name);
    ...
    }
    You are adding items to a list while iterating over them causing a ConcurrentModificationException. This shouldn't happen when using an iterator or making the List synchronized using
    Collections.synchronizedList(List aList).

    Anyway what are you really after? A list of entities or a List of names?

    Code:
    List<Entity> witnesses = event.getEntity().getNearbyEntities(10, 10, 10);
    for(Entity y : witnesses){
    if(y instanceof HumanEntity){
    String name = ((HumanEntity) y).getName();
    witnesses.add(name);
    }
    First you get a List of entities from an event. Then you try to add Strings to that list.
    I dont really think this is what you want (or even works hehe). You want a List of entities to iterate over and a list of names from the entities. Then iterate over the List of entities and add the names to the other list. This way a ConcurrentModificationException shouldn't even happen.

    Next to that can you tell what you are trying to achieve? Because we can spoon you all the code, but in the end it's not about the code but about the implementation. If you tell what you are trying to achieve we might be of much bigger help ;)
     
Thread Status:
Not open for further replies.

Share This Page