Refined Storage

Refined Storage

77M Downloads

Server thread hang in exporter

imerr opened this issue ยท 2 comments

commented

Issue description:

Sometimes my world would just hang forever.
After a bunch of fiddling around and figuring out how I'd even attach a debugger (I don't do java dev) I attached one and here's the stack trace in the server thread:

[...]
calculate:109, CraftingTask (com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task)
schedule:321, CraftingManager (com.raoulvdberge.refinedstorage.apiimpl.autocrafting)
doExport:169, NetworkNodeExporter (com.raoulvdberge.refinedstorage.apiimpl.network.node)
update:74, NetworkNodeExporter (com.raoulvdberge.refinedstorage.apiimpl.network.node)
onWorldTick:23, NetworkNodeListener (com.raoulvdberge.refinedstorage.apiimpl.network)
invoke:-1, ASMEventHandler_553_NetworkNodeListener_onWorldTick_WorldTickEvent (net.minecraftforge.fml.common.eventhandler)
invoke:90, ASMEventHandler (net.minecraftforge.fml.common.eventhandler)
post:182, EventBus (net.minecraftforge.fml.common.eventhandler)
onPostWorldTick:273, FMLCommonHandler (net.minecraftforge.fml.common)
func_71190_q:776, MinecraftServer (net.minecraft.server)
func_71217_p:668, MinecraftServer (net.minecraft.server)
func_71217_p:185, IntegratedServer (net.minecraft.server.integrated)
run:526, MinecraftServer (net.minecraft.server)
run:745, Thread (java.lang)

I left out anything above calculate:109 since that does seem to work correctly, attempting to step out of the calculate:109 (which should complete fairly quickly, correct?) just waits indefinitely

The code in question seems to be the while loop at https://github.com/raoulvdberge/refinedstorage/blob/06174d743af67a2e00695d32fdb5262f4afe049d/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/autocrafting/task/CraftingTask.java#L106
quantity seems to always stay 1 & recursedPattern is null
So the only way for this to loop would be currentPattern.getQuantityPerRequest to always return 0?

Disconnecting the exporter in question via mcedit allowed me to go in-game the issue & checking the crafting templates they all seem to be in order and manually starting a crafting job works fine too

Not quite sure what other info you might need.
The item to craft in question was an IC2 quad fuel rod, does have durability - so maybe that's confusing the comparer? https://github.com/raoulvdberge/refinedstorage/blob/020e92c6a19b8f3f74ef42f7092c9c7b57f92d49/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/autocrafting/CraftingPattern.java#L245

I just checked the durability on the exporter and indeed the durability is 2 points down from the crafting recipe (19998 in the exporter vs 20000 originally), so you probably just need to add a check something like https://github.com/raoulvdberge/refinedstorage/blob/mc1.12/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/autocrafting/task/CraftingTask.java#L144 to getQuantityPerRequest, probably based on the exporter settings?

What happens:

Server thread hangs

What you expected to happen:

Server thread does not hang

Steps to reproduce:

  • Create a pattern for a diamond pickaxe
  • Grab diamond pickaxe, mine a few blocks so the durability goes down
  • Place exporter onto inventory
  • Set exporter to export damaged diamond pickaxe
  • Set exporter to ignore damage
  • Add crafting card to exporter
  • Server thread is now hanging

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

  • Minecraft: 1.12.2
  • Forge: 14.23.3.2698
  • Refined Storage: 1.5.34 (but happened on 1.5.33 aswell)

Does this issue occur on a server? [yes/no] I've only tested singleplayer

(Sorry if this seems rambly, I only figured out the cause properly after writing the initial issue)

commented

Thanks for investigating so good, but unfortunately it's no longer relevant as I'm rewriting autocrafting.

commented

Lol, gotta look at ae2's code and see what you can copy?