Wesley1808 / ServerCore

A mod that aims to optimize the minecraft server.
75 stars 11 forks source link

Intermittent ArrayIndexOutOfBoundsException crash during block updates #78

Closed object-Object closed 5 months ago

object-Object commented 10 months ago

Describe the bug We're getting sporadic server crashes with the exception java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 257. This appears to be happening in the following mixin method:

https://github.com/Wesley1808/ServerCore/blob/5d60a32a1119a34c7d2a38d99e4238ff36c57c9d/common/src/main/java/me/wesley1808/servercore/mixin/optimizations/ticking/chunk/broadcast/ServerChunkCacheMixin.java#L39-L42

Log 1: https://mclo.gs/VqUt8x7 Crash 1: https://mclo.gs/PWqPTe0

Log 2: https://mclo.gs/5GNKdXj Crash 2: https://mclo.gs/BRyJIda

Reproduce Unfortunately I have no idea how to reproduce this crash. It appears to just happen intermittently, and I don't see anything relevant in the logs. The only thing I can think of is that both crashes were for entities in the spawn chunks, which have a pretty large amount of block entities. I'd be happy to switch to a debug jar with some extra logging if it would help troubleshoot this.

Versions ServerCore: 1.3.3 Minecraft: 1.19.2 Quilt Loader: 0.19.0 Quilt (QFAPI/QSL): qfapi-4.0.0-beta.30_qsl-3.0.0-beta.29_fapi-0.76.0

Full modlist (it's a lot, sorry): https://github.com/HexxyCraft/modpack/tree/master/mods

Wesley1808 commented 10 months ago

Normally that kind of crash would suggest concurrent access to the set. Do you know if any of your mods are trying to tick their block entities (or maybe even chunks) async?

At least not all BE's are, because the ones causing the crash were ticked on the server thread (which makes it very unlikely to be their fault it crashed).

Wesley1808 commented 10 months ago

I have made a quick version for debugging it, but I'm still having trouble reproducing it. If you want to, you can give it a try. It detects when the method is called from any non-server thread and prints the stacktrace. Do note that this will probably spam your logs full if this happens often.

https://cdn.discordapp.com/attachments/1099590675441397810/1163089807036141629/servercore-fabric-1.3.51.19.2.jar (github wouldn't let me attach it)

object-Object commented 10 months ago

Do you know if any of your mods are trying to tick their block entities (or maybe even chunks) async?

It's possible, we have a few fairly experimental mods in the pack, but off the top of my head I don't know which mod it would be.

Also - I can definitely give it a try, but the link appears to be a 404 (probably Discord's new policy of making file links temporary so you can't use them as a file server).

Wesley1808 commented 5 months ago

Closing this as the crash isn't really caused by servercore (just makes it more likely). Relevant issue: https://github.com/SamsTheNerd/ducky-periphs/issues/36