foxynotail / create-storage-mod-fabric

Create Storage Mod
https://www.curseforge.com/minecraft/mc-mods/create-storage
GNU General Public License v3.0
16 stars 12 forks source link

Crash: Race condition when breaking simple storage boxes in network #12

Open Kaiede opened 4 months ago

Kaiede commented 4 months ago

I was playing around in a single-player world before deploying this add-on in my SMP uncovered something that looks like a race condition that leads to a crash. Specifically, if you have a belt feeding/extracting items to/from a storage network, and then change the size of the network by removing one of the simple storage boxes from the network, it looks like it's possible that the 'slot' being interacted with can become invalid during a transaction.

My Setup:

In my case, the setup used a second set of storage drawers from another mod that was feeding the belt, but really any setup that can keep the belts fed should be able to trigger this bug. Probably a bit easier to hit in creative since breaking is instant.

Test


[08:14:51] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.class_148: Ticking block entity at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:901) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:824) ~[client-intermediary.jar:?] at net.minecraft.class_1132.method_3748(class_1132.java:105) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:671) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265) ~[client-intermediary.jar:?] at java.lang.Thread.run(Unknown Source) ~[?:?] Caused by: java.lang.RuntimeException: Encountered an exception while invoking a transaction outer close callback. at net.fabricmc.fabric.impl.transfer.transaction.TransactionManagerImpl$TransactionImpl.close(TransactionManagerImpl.java:159) ~[fabric-transfer-api-v1-3.3.5+8dd72ea377-394e3c6b4f860686.jar:?] at net.fabricmc.fabric.impl.transfer.transaction.TransactionManagerImpl$TransactionImpl.commit(TransactionManagerImpl.java:186) ~[fabric-transfer-api-v1-3.3.5+8dd72ea377-394e3c6b4f860686.jar:?] at com.simibubi.create.foundation.blockEntity.behaviour.inventory.InvManipulationBehaviour.insert(InvManipulationBehaviour.java:92) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at com.simibubi.create.content.kinetics.belt.transport.BeltFunnelInteractionHandler.checkForFunnels(BeltFunnelInteractionHandler.java:98) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at com.simibubi.create.content.kinetics.belt.transport.BeltInventory.tick(BeltInventory.java:157) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at com.simibubi.create.content.kinetics.belt.BeltBlockEntity.tick(BeltBlockEntity.java:128) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at com.simibubi.create.foundation.blockEntity.SmartBlockEntityTicker.tick(SmartBlockEntityTicker.java:15) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at net.minecraft.class_2818$class_5563.method_31703(class_2818.java:662) ~[client-intermediary.jar:?] at net.minecraft.class_2818$class_5564.method_31703(class_2818.java:716) ~[client-intermediary.jar:?] at net.minecraft.class_1937.method_18471(class_1937.java:470) ~[client-intermediary.jar:?] at net.minecraft.class_3218.method_18765(class_3218.java:390) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:897) ~[client-intermediary.jar:?] ... 5 more Caused by: java.lang.IndexOutOfBoundsException: Index 11 out of bounds for length 10 at jdk.internal.util.Preconditions.outOfBounds(Unknown Source) ~[?:?] at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source) ~[?:?] at jdk.internal.util.Preconditions.checkIndex(Unknown Source) ~[?:?] at java.util.Objects.checkIndex(Unknown Source) ~[?:?] at java.util.ArrayList.get(Unknown Source) ~[?:?] at net.minecraft.class_2371.get(class_2371.java:47) ~[client-intermediary.jar:?] at net.fxnt.fxntstorage.controller.StorageControllerEntity.method_5438(StorageControllerEntity.java:133) ~[fxntstorage-0.14-1.20.1-FABRIC+1.20.1.jar:?] at net.fabricmc.fabric.impl.transfer.item.InventorySlotWrapper.getStack(InventorySlotWrapper.java:57) ~[fabric-transfer-api-v1-3.3.5+8dd72ea377-394e3c6b4f860686.jar:?] at net.fabricmc.fabric.impl.transfer.item.InventorySlotWrapper.onFinalCommit(InventorySlotWrapper.java:149) ~[fabric-transfer-api-v1-3.3.5+8dd72ea377-394e3c6b4f860686.jar:?] at net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant.afterOuterClose(SnapshotParticipant.java:139) ~[fabric-transfer-api-v1-3.3.5+8dd72ea377-394e3c6b4f860686.jar:?] at net.fabricmc.fabric.impl.transfer.transaction.TransactionManagerImpl$TransactionImpl.close(TransactionManagerImpl.java:156) ~[fabric-transfer-api-v1-3.3.5+8dd72ea377-394e3c6b4f860686.jar:?] at net.fabricmc.fabric.impl.transfer.transaction.TransactionManagerImpl$TransactionImpl.commit(TransactionManagerImpl.java:186) ~[fabric-transfer-api-v1-3.3.5+8dd72ea377-394e3c6b4f860686.jar:?] at com.simibubi.create.foundation.blockEntity.behaviour.inventory.InvManipulationBehaviour.insert(InvManipulationBehaviour.java:92) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at com.simibubi.create.content.kinetics.belt.transport.BeltFunnelInteractionHandler.checkForFunnels(BeltFunnelInteractionHandler.java:98) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at com.simibubi.create.content.kinetics.belt.transport.BeltInventory.tick(BeltInventory.java:157) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at com.simibubi.create.content.kinetics.belt.BeltBlockEntity.tick(BeltBlockEntity.java:128) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at com.simibubi.create.foundation.blockEntity.SmartBlockEntityTicker.tick(SmartBlockEntityTicker.java:15) ~[create-fabric-0.5.1-f-build.1417+mc1.20.1.jar:?] at net.minecraft.class_2818$class_5563.method_31703(class_2818.java:662) ~[client-intermediary.jar:?] at net.minecraft.class_2818$class_5564.method_31703(class_2818.java:716) ~[client-intermediary.jar:?] at net.minecraft.class_1937.method_18471(class_1937.java:470) ~[client-intermediary.jar:?] at net.minecraft.class_3218.method_18765(class_3218.java:390) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:897) ~[client-intermediary.jar:?] ... 5 more