Linking train cars leads to infinite recursion in RollingStockImpl.java
areyoutoo opened this issue ยท 11 comments
Is there an existing issue for this?
- I have searched the existing issues
Description of the Bug
Server is running ATM9 0.2.41 but I anticipate this bug is reproducible using just Railcraft Reborn.
One of my players did a tricky thing unlinking and relinking some train cars and minecarts. We have done our best to recapture the exact sequence of events in the steps to reproduce. As soon as the cars were linked, the server became unresponsive. Crash report is showing what looks like an infinite recursion with mods.railcraft.world.entity.vehicle.RollingStockImpl.train()
calling itself more than 1000 times.
Looking at the source code, that method looks simple enough:
@Override
public Train train() {
return this.validateTrainOwnership() ? this.train : this.frontLink.train();
}
There is only one path here where that method would call itself, so I am guessing that this.frontLink
is either a self-reference, or perhaps multiple carts pointing at each other in a loop that will never end.
Railcraft Reborn version
1.0.10
NeoForge/Forge version
47.2.19
Minecraft version
1.20.1
Minecraft server
Yes
To Reproduce
These steps are being recounted to me by a player. He's doing his best from memory, but may not be exact.
- Place a TrackRelayer
- Place a Minecart with Chest
- Connect the TrackRelayer and Minecart with Chest
- Place a train ahead of the TrackRelayer
- Place a Minecart behind the train
- Connect the train and the Minecart
- Connect the Minecart to the TrackRelayer
- At this point, he observed that the TrackLayer stopped laying track
- Use a crowbar to unlink the cars
- Relink the cars
At the exact moment he relinked the cars, server crashed.
Expected behavior
Expected:
Server does not crash.
Observed:
Server crashed. Log output seems to indicate infinite recursion in RollingStockImpl.train
method.
Logs & Environment
java.lang.StackOverflowError: Exception in server tick loop
at mods.railcraft.world.entity.vehicle.RollingStockImpl.train(RollingStockImpl.java:460) ~[railcraft-reborn-1.20.1-1.0.10.jar%23790!/:1.20.1-1.0.10] {re:classloading}
at mods.railcraft.world.entity.vehicle.RollingStockImpl.train(RollingStockImpl.java:460) ~[railcraft-reborn-1.20.1-1.0.10.jar%23790!/:1.20.1-1.0.10] {re:classloading}
at mods.railcraft.world.entity.vehicle.RollingStockImpl.train(RollingStockImpl.java:460) ~[railcraft-reborn-1.20.1-1.0.10.jar%23790!/:1.20.1-1.0.10] {re:classloading}
at mods.railcraft.world.entity.vehicle.RollingStockImpl.train(RollingStockImpl.java:460) ~[railcraft-reborn-1.20.1-1.0.10.jar%23790!/:1.20.1-1.0.10] {re:classloading}
at mods.railcraft.world.entity.vehicle.RollingStockImpl.train(RollingStockImpl.java:460) ~[railcraft-reborn-1.20.1-1.0.10.jar%23790!/:1.20.1-1.0.10] {re:classloading}
(it goes on like this for 1000+ lines)
Screenshots & Video
No response
@PokeMaserJ @AylanJ123 @AnyankaT @areyoutoo
I need a clear list of actions I need to do to make this bug happen.
Try doing this first on a server with only railcraft installed and see if it happens.
@Edivad99 I managed to make it happen again in a private test server. But it wasn't straight forward. I linked-unlinked tons of times until I got it working (By working I mean crashing). Not like, spam. But I spent at least a solid minute looking for different combinations and didn't realize which one was that got it crashed. I feel like, depending on the order, it loops forever. May have to do with the info or packets doing race conditions and not signaling properly what the player actually did. I just remember it crashed in a quick motion.
@Edivad99 Jesus, is difficult to find out the exact order. Almost feels random, the only thing I know is that has to do with linking at least 3 different elements. Doesn't happen between 2. I'll try again later.
But it's never happened to me and I'm currently creating a bunch of trains to fix another problem and I've never seen this error
Make sure is a dedicated server environment, couldn't get it working on a singleplayer/LAN environment.
But it's never happened to me and I'm currently creating a bunch of trains to fix another problem and I've never seen this error
@AylanJ123 @AnyankaT @areyoutoo Have you tried the latest version? Is the bug still present?
@Edivad99 Going to try, is difficult but not impossible.
The same thing happened on our dedicated server (the link by PokeMasterJ above) last weekend. We also tried using //regen from WorldEdit, we regenerated the entire chunk, which STILL did not remove the entities. We ended up having to set up a redstone clock with specific /kill commands at a distance, while a player stuck in that chunk logged in - hoping to set off the command between the time the chunk loaded and the server crashed. After two tries, we were able to finally kill the two carts and the players in that chunk could then log in again without crashing the server.