GregTechCE / GregTech

GregTech rewrite for modern versions of Minecraft
GNU Lesser General Public License v3.0
271 stars 150 forks source link

Game crash on connecting LV machine to MV energy cable #1046

Open LAGIdiot opened 4 years ago

LAGIdiot commented 4 years ago

Version: 1.9.1 (dev build on 853ffbc44a239df957fbe4a434f2733810253e41)

Environment: GTCE dev; new world generated

Setup: 2020-03-25_20 16 32 HV Diesel generator with fuel in HV Transformer (transform down) Cable (any MV and higher) MV Machine (probably any, tested on Electrolyzer, Fermenter)

Steps to reproduce: Place LV machine (probably any, tested on Electric Furnace, Autoclave, Bending Machine) on Cable

Expected:

Actual:

pyure commented 4 years ago

@LAGIdiot I can't reproduce this on the master branch just fyi. image

LAGIdiot commented 4 years ago

I think that MV machine on end of my setup is crucial as it works as consumer.

ALongStringOfNumbers commented 3 years ago

I just tried to reproduce this, and yes, the MV machine is needed to reproduce the crash.

LAGIdiot commented 3 years ago

Thanks for reproducing this issue. Can you please mention version on which you were able to do it and if possible steps if they are more clearer than these provided by me.

ALongStringOfNumbers commented 3 years ago

I was able to reproduce this in a development environment (That is up to date against the 1.10.5.582 commits) by following the exact instructions provided in the initial issue. This is the crash log retrieved from that crash: Crash

However, when I tried to reproduce this in a non-development environment, with a minimal modlist, I was not able to produce this crash. The modlist for the minimal environment is here: modlist

LAGIdiot commented 3 years ago

Well this is quite strange as it does probably happen only on dev environment but I will accept it anyway.

serenibyss commented 3 years ago

After doing a lot of testing in-game and in the code, I discovered that the crash is caused because the call to energyNet.getAllNodes().get(destinationPos) returns a null, so when .blockedConnections is called on it, it throws a NPE, causing a crash. I'm not certain why this is, but I have a few more specificities regarding when the crash occurs as well.

First of all, the crash only occurs when the lower-voltage machine is placed on a cable that has no other connections. This includes the Transformer and the Electrolyzer, in this case. I also still could not reproduce this issue outside of a dev environment.

It only seems to appear when a Transformer is present. I tested this out using a Transformer stepping down from EV -> HV, and it caused the same crash when an MV machine was placed on the line. I also tested out if the issue had to do with simply more than one amp, but that did not result in a crash. It also did not crash when placing an LV machine on a normal MV line with no Transformer.

I also wanted to point out that we cannot simply check for if the node at destinationPos is null and skip, since this would potentially introduce amperage problems in the energyNet, as this blockedConnections call is important to the calculation of the total amperage of the energyNet. Hopefully this helps, sorry that I couldn't yet determine a fix, or figure out more in-depth why a Transformer specifically causes this.