GregTechCEu Modern

GregTechCEu Modern

6M Downloads

Unrecoverable server crash from battery buffer sending negative energy to AE2 acceptor (or possibly EU P2P tunnel)

aevns opened this issue ยท 1 comments

commented

Checked for existing issues

  • I have checked for existing issues, and have found none.

Tested latest version

  • I have checked that this occurs on the latest version.

GregTech CEu Version

v1.4.4

Minecraft Version

1.20.1

Recipe Viewer Installed

EMI

Environment

Singleplayer

Cross-Mod Interaction

Yes

Other Installed Mods

Monifactory [modpack]

Expected Behavior

A LuV battery buffer was feeding into a wire with an AE2 energy acceptor and EU P2P [input] component connected to it, as well as a chain of step down transformers with their own EU P2P [input] components attached. A redstone P2P component was attached to the battery's energy detector cover, for regulating power production. I had no problems with the setup in previous energy tiers, and for several hours into LuV.

Actual Behavior

When autocrafting activated many machines simultaneously, a sudden spike in power demand from machines connected to the battery buffer through the EU P2P tunnels coincided with a server crash. Attempting to reload the save results in the same crash.

Steps to Reproduce

I can't provide steps to reproduce the crash, but if needed I may be able to provide a save file.
crash-2024-10-06_11.40.43-server.txt

Additional Information

Exception
java.lang.IllegalArgumentException: amt must be >= 0
was raised from
appeng.me.service.EnergyService.injectProviderPower
called a few functions deep from
com.gregtechceu.gtceu.api.capability.compat.EUToFEProvider$GTEnergyWrapper.acceptEnergyFromNetwork

Looking at the AE2 repo,
public double extractProviderPower(double amt, Actionable mode) { Preconditions.checkArgument(amt >= 0, "amt must be >= 0");
checks if it's passed a negative value and throws an exception immediately. Possibly related, the battery buffer had a negative energy buffer according to the crash report
{ForgeCaps:{},batteryInventory:{Items:[{Count:1b,Slot:0,id:"gtceu:luv_vanadium_battery",tag:{Charge:149344256L}}, ... ],Size:16},cover:{ ... },uid:{id:"gtceu:energy_detector_advanced",side:2}}},energyContainer:{energyStored:-131072L,isDistinct:0b},isWorkingEnabled:1b,paintingColor:-1}

commented

Using NBTExplorer to change the battery buffer's energyStored from -131072 to 0 allowed me to load the save file without crashing, so that was clearly responsible. How energyStored went negative though, I don't know. Might need to change some data validation in acceptEnergyFromNetwork, possibly elsewhere(?)