dslake / WorldDownloader

Clones a Minecraft multiplayer world from a remote server to your singleplayer folder
http://www.minecraftforum.net/topic/1444862-
62 stars 19 forks source link

Crash while stopping the download (ConcurrentModificationException) #9

Closed nairol closed 12 years ago

nairol commented 12 years ago

Original report: http://www.minecraftforum.net/topic/1444862-142-world-downloader-mod/page__st__140#entry18833574

MC crashes half the time when I click Stop Download.

Installed mods:

Minecraft has crashed!      
      ----------------------      

Minecraft has stopped running because it encountered a problem; Unexpected error

--- BEGIN ERROR REPORT e3760d2a --------
Generated 28/10/12 20:50

- Minecraft Version: 1.4.2
- Operating System: Windows XP (x86) version 5.1
- Java Version: 1.7.0_09, Oracle Corporation
- Java VM Version: Java HotSpot™ Client VM (mixed mode), Oracle Corporation
- Memory: 666903560 bytes (636 MB) / 810942464 bytes (773 MB) up to 810942464 bytes (773 MB)
- JVM Flags: 2 total; -Xms800m -Xmx800m
- AABB Pool Size: 1069 (59864 bytes; 0 MB) allocated, 15 (840 bytes; 0 MB) used
- LWJGL: 2.4.2
- OpenGL: GeForce 7300 LE/PCI/SSE2/3DNOW! GL version 2.1.2, NVIDIA Corporation
- Is Modded: Very likely
- Type: Client
- Texture Pack: Default
- Profiler Position: N/A (disabled)
- Vec3 Pool Size: 1376 (77056 bytes; 0 MB) allocated, 12 (672 bytes; 0 MB) used
- World MpServer Entities: 1 total; [axc['evil_eyes269'/98611, l='MpServer', x=-3464.31, y=65.62, z=3368.00]]
- World MpServer Players: 1 total; [axc['evil_eyes269'/98611, l='MpServer', x=-3464.31, y=65.62, z=3368.00]]
- World MpServer Chunk Stats: MultiplayerChunkCache: 121
- Forced Entities: 2 total; [ayn['burnfireblaze100'/85456, l='MpServer', x=-3593.03, y=69.41, z=3329.75], axc['evil_eyes269'/98611, l='MpServer', x=-3464.31, y=65.62, z=3368.00]]
- Retry Entities: 0 total; []

java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
    at java.util.ArrayList$Itr.next(Unknown Source)
    at xe.h(SourceFile:1143)
    at net.minecraft.client.Minecraft.l(SourceFile:1278)
    at ara.l(MinecraftAppletImpl.java:45)
    at net.minecraft.client.Minecraft.J(SourceFile:582)
    at net.minecraft.client.Minecraft.run(SourceFile:534)
    at java.lang.Thread.run(Unknown Source)
--- END ERROR REPORT 5bdce15b ----------

I think it is related to Optifine but haven't found out what the problem is.

nairol commented 12 years ago

ConcurrentModificationException documentation:

This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible.

For example, it is not generally permissible for one thread to modify a Collection while another thread is iterating over it. In general, the results of the iteration are undefined under these circumstances. [...] Note that this exception does not always indicate that an object has been concurrently modified by a different thread. If a single thread issues a sequence of method invocations that violates the contract of an object, the object may throw this exception. For example, if a thread modifies a collection directly while it is iterating over the collection with a fail-fast iterator, the iterator will throw this exception. [...]

xe.h [Line 1143] translates to World.updateEntities() [Line 1905]

        this.theProfiler.endStartSection("tileEntities");
        this.scanningTileEntities = true;
        var5 = this.loadedTileEntityList.iterator();

        while (var5.hasNext())
        {
            TileEntity var6 = (TileEntity)var5.next();

Last line causes the Exception by trying to iterate over World.loadedTileEntityList while it is modified elsewhere. (?)

Other places in vanilla Minecraft that access World.loadedTileEntityList:

My MCP and Eclipse setup is not up to date so I'll just leave this here as a starting point.

nairol commented 12 years ago

addTileEntity(TileEntity) is called by WDL in importTileEntities(Chunk). importTileEntities(Chunk) is called while saving a chunk. This is asynchronous to the thread where updateEntities() is executed. This could be the problem.

Of the places that access World.loadedTileEntityList that I listed in the above comment, only one forgets to check the kind-of-mutex World.scanningTileEntities and unfortunately WDL uses exactly that method. My fault. :(

I think we just have to port the method WDL.importTileEntities(Chunk) to using World.addTileEntity(Collection) or World.setBlockTileEntity(...).

I'll test this tomorrow...

dslake commented 12 years ago

Thanks for diagnosing that one. Good catch. If you have time to test it out, that's great. If not, I can get get to it on Friday PDT.

nairol commented 12 years ago

Actually I can't really test if it doesn't crash anymore because I haven't gotten it to crash with WDL 1.4.2 beta 6 and Optifine at all. Maybe I have to try the other mods as well.

nairol commented 12 years ago

This needs to be tested by the original bug reporter from the forum. I couldn't reproduce the bug even with all the listed mods installed.

dslake commented 12 years ago

I posted v2 BETA 7 on the forum thread and a message quoting the original reporter. I'll close this issue now and reopen if it's reported again.