Fast Async World Save[Forge/Fabric]

Fast Async World Save[Forge/Fabric]

21M Downloads

[Bug]: Crash (Concurrent Modification Exception) on at least some platforms

team1257Simon opened this issue · 3 comments

commented

Describe the bug you're experiencing

This crash is somewhat difficult to pin down — it took me a rather long time to tie it to this mod — but it happens seemingly at random on my 1.21.1 instance with this mod enabled and never occurs when I disable it (and no other mods in the pack). The crash occurs at some point during the internal stream operations accessing the world data, though I'm not entirely sure what it's conflicting with. The error message is, of course, unhelpful, as most things to do with internal Java code tend to be.

Reproducability

As far as I know, the crash only appears to happen when saving the world and loading a chunk at the same time. I'm not 100% certain of any other factors.
I've attached a crash log from one of the times this happened to me last month and pasted another one in a gist -- all the ones that have happened to me since were essentially the same, and the crash hasn't happened to me since I disabled the mod (where it happened rather frequently before this).
crash-2024-10-10_21.20.20-server(1).txt

Mod up to date

  • Before submitting this issue I updated to the newest version and reproduced it

Minecraft version

1.21.1

Modloader version

Forge

Logs

https://gist.github.com/team1257Simon/3dce2abd1b06361ca4ad59e8843ea73e

commented

This mod actually does not touch the world async at all, it saves all stuff in the mainthread and then passes the data along to be written to file offthreaed. Your error is related to chunks getting loaded/unloaded, which this mod is unrelated to, its impossible to be related to it.

It may be related to other of my mods like betterchunkloading, though none of those do async accesses.
Its probably a good idea to debug offthread chunkloading, cupboard has a config option to print those chunk loads to the log, I'd start with enabling that

commented

The tricky thing with this error is that it doesn't trace very well because the container that's throwing it could be picking up an access to a shared reference that's itself a field stored in an object referenced by the container...the fact that you don't think that it's possible for it to be related doesn't change the fact that the crash happens with this mod enabled even after a clean reinstall and after changing my JVM and everything, but stops as soon as I disable this mod and no others.
For one thing, the act of saving a chunk DOES modify the chunk's active data in memory -- the game tracks whether a chunk needs to be saved or not, then updates the chunk after it's saved -- so if you're moving it to another thread then that absolutely risks an implementation-specific crash if you're also loading chunks at the same time (the crash tends to happen in circumstances where the game tries to save at the same times as chunks are being loaded, like when I teleport to a Waystone). The way Java checks for data races is pretty opaque, so at the end of the day it's impossible to rule out the possibility.

commented

no the way this mod works is it saves all data to a compound on the mainthread and then passes that along to the offthread save to file. So the original objects/data is not being touched