Refined Storage

Refined Storage

77M Downloads

Edge case not accounted for that will cause a server to crash on startup

Skinklizzard opened this issue ยท 5 comments

commented

with the current code on update apiimpl/network/Network.java line 173

world.setBlockState(pos, world.getBlockState(pos).with(ControllerBlock.ENERGY_TYPE, energyType));

is called, in the rare case where the block you are setting the state of is actually no longer a controller this causes a crash because of a java illegal argument exception.

although for the most part this shouldn't happen I have seen it, specifically in the case where the mod has been removed and re added, the node and network data files still exist and point to a location in world being a controller but said location is now minecraft:air.

Issue description:

edge case causing server crash

What happens:

attempt to assign an enum property on a block that doesn't contain that property

What you expected to happen:

check that the block is in fact what it is meant to be

Steps to reproduce:

  1. unknown
    ...

Version (make sure you are on the latest version before reporting):

  • Minecraft: 1.14.4
  • Forge: 28.1.107
  • Refined Storage:

Does this issue occur on a server? [yes/no] yes

If a (crash)log is relevant for this issue, link it here:

java.lang.IllegalArgumentException: Cannot set property EnumProperty{name=energy_type, clazz=class com.raoulvdberge.refinedstorage.block.ControllerBlock$EnergyType, values=[off, nearly_off, nearly_on, on]} as it does not exist in Block{minecraft:air}
	at net.minecraft.state.StateHolder.func_206870_a(SourceFile:106) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at com.raoulvdberge.refinedstorage.apiimpl.network.Network.update(Network.java:173) ~[?:1.7.1] {re:classloading}

full link
https://pastebin.com/s4ZSfaJe

commented

The ATM4 (All The Mods 4) Test Server is currently in a crash loop due to this...not sure how it happened, or even where the block is to try to fix it.

commented

for servers already in the crash loop a not ideal work around to get them booted again would be to go to the world/data/ folder and move the minecraft_overworld_refinedstorage_networks.dat and minecraft_overworld_refinedstorage_nodes.dat out to a backup folder elsewhere, then start the server.
this will have the server recreate those nodes and networks from the blocks in the region files, but you'll loose the current links and although the disk data still exists the disk items will no longer be linked in world.

similar procedure applies if you have a rs system in one of the other dimensions just the path becomes world/DIM{something}/data/
and overworld is replaced with the dimension name in the data file names.

you can then use something like nbtexplorer to manually copy the disk drive inventory data from the nodes backup to the newly generated files to restore the disk links.

commented

After trying all that, I decided to add a line of code and compile my own version of the mod to fix the issue... :P

commented

yea that's definitely the simpler option. I'm not sure how minecraft threading works or if its a thing at all, but a race condition of two threads hitting the same block should be significantly less common than the current edge case anyway.

commented

I'm not intimately familiar with the code, and only skimmed the sections I saw on EnergyType...but unless I'm mistaken, in your race condition, and it's a Controller block that the server thinks is an Air block, it'll revert to the default Energy Type (which is OFF)...right? Compared to what's currently happening where it's an Air block the server thinks should be a Controller, and the mod is creating the java.lang.IllegalArgumentException crash.