Crash when replacing cables which are connected to Industrial revolution machines with cables from Powah
AlexiyOrlov opened this issue · 28 comments
Describe the bug
Game crashed when I replaced some of the Techreborn energy cables with cables from Powah which were connected to some Industrial revolution machines
Steps to Reproduce
Steps to reproduce the behavior:
- Place some machine from Industrial Revolution
- Connect it to an energy source via Techreborn cables
- Try to replace these cables with Powah cables
Screenshots
I can't add screenshots because the game now is always crashing
Environment (please complete the following information with the version):
- Minecraft: 1.19.2
- Mod Loader: fabric
Logs
Log
Additional context
That field is what I was missing.
I also looked up the exception coming from the fabric energy api and it said that the mods must check for this.
#3085 seems related / same
Confirmed. We were connecting solar panels with energy storage from Powah using Powah cables.
The energy storage was configured to accept energy on one side and allow extraction on the other side. on the extraction side, again there were powah cables connected to feed into Tech Reborn and AE2 machines.
The solar panels themselves were connected using copper cables and then fed into the powah cables.
The crash seemed to occur exactly when the (industrial) solar panels ran out of stored power (it was night)
MC 1.19, Dreamcraft FABRIC modpack
//Edit: Playing multiplayer. The server does not start anymore so world is permanently damaged. Same issue again and again.
I discussed this with a friend of mine and we think it COULD be the case that powah cables are pulling energy from a tech reborn cable in the same tick when TR cables are trying to PUSH the SAME energy?
I mean like double substraction somewhere? Maybe this is then saved to network energy somewhere which causes a value to drop below 0 that must not become negative causing the crash again and again? Maybe a cable who's stored energy became less than zero, which is then "pushing" the negative energy to the neighboring cable?
I discussed this with a friend of mine and we think it COULD be the case that powah cables are pulling energy from a tech reborn cable in the same tick when TR cables are trying to PUSH the SAME energy?
I mean like double substraction somewhere? Maybe this is then saved to network energy somewhere which causes a value to drop below 0 that must not become negative causing the crash again and again? Maybe a cable who's stored energy became less than zero, which is then "pushing" the negative energy to the neighboring cable?
Would still be a bug. If I read it correctly, the mods should be checking for negative values.
Absolutely agree.
When looking at the code, TR checks for "maxAmount" being "NotNegative" and this method throws an exception when the value is <0.
This it not the source of evil but mybe it could be a workaround to just catch this exception and return 0?
This is just an idea we had yesterday thinking about it while falling half asleep 🤣
Some more hints regarding the issue itself:
- We produced it on 5.4.0
- We then upgraded to 5.7.0 and the issue still persisted (but the world was already in the "defective" state)
- I tried to reproduce this in my singleplayer world and was not able to. Eighter it does not happen in SP mode or the issue needs a very special constellation to happen (mybe it only happens on a specific interaction when the network is near-empty?)
From crawling the code and thinking about what we did, I thing the issue must exist withing interaction between the cables.
Our cabling looks like this:
SP CC CC CC PC PC PC EC PC PC [Machines]
SP being Solar Panel, CC Copper Cable, EC Powah Energy Cells, PC Powah Cables, Machines being AE2 ME Core and TR Machines (grinder and furnace)
Before the crash happened, the solar panels were fully charged and the bold marked cable was missing. All the network on the other side was completely discharged.
I placed the missing Power Cable to connect the copper cables to the power cables and a few seconds later the server crashed.
The friend I was playing with had on of the solar panel's GUIs open and said the crash happened in the moment it ran out of stored power.
Side note: we have three basic and two industial solar panels
Crawling the region file we found out that the copper cables got saved with negative energy values.
I do not believe that this is powah's fault, I read through the code, added some negativity checks literally everywhere and it still happens.
AE2 might not distribute the power properly.
I can only say that definitely the copper cables from TR had the negative values in their NBT in the end.
We replaced all copper cables by Powah cables and had no issues anymore.
Everythign else was just assumption from an open discussion.
Thing is. I do not have anything but powah cables and p2p tunnels in my system.
Then it might still be TR generator type connected to powah cables?
Becausr in their core both use the same code for power distribution.
If you have for example
[TR Solar] -> [Powah Cable] -> [AE2 P2P] -> ...
In this case AE2 does not even interact with TR. It interacts with Powah. And powah interacts with TR.
The exception we're seeing is raised from TR's stack.
The power generator is powah thermo. I see an ae2 commit from yesterday that sounds like a fix. Building it now.
We should make sure that this is not a different issue.
Can you post a crash stacktrace?
The point why I got powah in mind is that any report you see always contains powah cables. This is why I think that poway misbehaves and CAUSES the issue. But it might also only be the spark that ignites the bomb
If you have for example
[TR Solar] -> [Powah Cable] -> [AE2 P2P] -> ...
In this case AE2 does not even interact with TR. It interacts with Powah. And powah interacts with TR.
The exception we're seeing is raised from TR's stack.
My exception is pointing at the thermo, which is sitting in the same spot as your solars. Had no issues until p2p was introduced.
I don't fully understand what powah does (I only checked the classes I saw in the stacktrace), but it might be one of those cables that just proxy whatever they are connected to. In which case it is indeed the spark, shifting the "blame".
Looking at AE2's code now.
We should make sure that this is not a different issue.
There is an open issue for it.
Technici4n/Powah#56
at appeng.parts.p2p.FEP2PTunnelPart$InputEnergyStorage.insert(FEP2PTunnelPart.java:88)
this is in the spot where on our stack is TechReborn...
Let me guess... You are EXTRACTING energy from AE2's P2P-Tunnel using (insert drumroll) Powah cables?
In our case btw there were no P2P tunnels implied. Only teh AE2 ME Controller attached to a powah cable.
the powah cabled was extracting from TR cables
In our case btw there were no P2P tunnels implied. Only teh AE2 ME Controller attached to a powah cable. the powah cabled was extracting from TR cables
Still checking ae2. Your log is gone from pastebin, can you upload it as a gist or a file, so I can see if it really mentions the same lines?
AE2 is indeed sending negative amounts.
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power 4
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power 8
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power 4
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power 4
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power 8
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power 4
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power 10
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power 16
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power -8 <<<
[00:27:03] [Server thread/INFO]: [STDOUT]: sending power -2 <<<
[00:27:03] [Server thread/ERROR]: Encountered an unexpected exception
net.minecraft.class_148: Ticking block entity
at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:879) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:819) ~[client-intermediary.jar:?]
at net.minecraft.class_1132.method_3748(class_1132.java:98) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:665) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:257) ~[client-intermediary.jar:?]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.IllegalArgumentException: Amount may not be negative, but it is: -2
at net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions.notNegative(StoragePreconditions.java:50) ~[fabric-transfer-api-v1-2.1.6+413cbbc790-e9d4a58328abaa4.jar:?]
The other one might be the same.
Are there any other blocks touching the powah cables? Narrowed it down to industrial revolution, which indeed has a history with this bug.
From what I have, I only see one line in ae2 that may cause this. I do not know what happens on your side anymore, as the original pastebin link is no longer valid. (you literally don't provide any logs)
I think I never posted our stack. Unfortunately I didn't keep a copy of the dumps. (I am not the OP of this issue)
I no longer understand this. There is indeed 1 sus line in ae2, that either gets triggered by having too many outputs or industrial revolution. But that may also just be fine.
so... is this related?
is there some fix?