Project Red - Exploration

Project Red - Exploration

27M Downloads

NullPointerException while updating neighbours

Vectrobe opened this issue ยท 16 comments

commented

a null check is missing while neighbor updating is being performed, particularly evident on moving machinery.

Description: Exception while updating neighbours

java.lang.NullPointerException: Exception while updating neighbours
at mrtjp.projectred.transmission.FramedBundledCablePart.calcStraightArray(bundledwires.scala:258)
at mrtjp.projectred.transmission.FramedBundledCablePart$$anonfun$calculateSignal$2.apply(bundledwires.scala:247)
at mrtjp.projectred.transmission.FramedBundledCablePart$$anonfun$calculateSignal$2.apply(bundledwires.scala:246)
at scala.collection.immutable.Range.foreach(Range.scala:160)
at mrtjp.projectred.transmission.FramedBundledCablePart.calculateSignal(bundledwires.scala:246)
at mrtjp.projectred.transmission.TBundledCableCommons$class.updateAndPropagate(bundledwires.scala:89)
at mrtjp.projectred.transmission.FramedBundledCablePart.updateAndPropagate(bundledwires.scala:241)
at mrtjp.projectred.transmission.Propagation.go(propagation.scala:213)
at mrtjp.projectred.transmission.PropagationRun$$anonfun$runLoop$1.apply(propagation.scala:177)
at mrtjp.projectred.transmission.PropagationRun$$anonfun$runLoop$1.apply(propagation.scala:177)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1174)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at mrtjp.projectred.transmission.PropagationRun.runLoop(propagation.scala:177)
at mrtjp.projectred.transmission.PropagationRun.start(propagation.scala:155)
at mrtjp.projectred.transmission.WirePropagator$.propagateTo(propagation.scala:78)
at mrtjp.projectred.transmission.WirePropagator$.propagateTo(propagation.scala:84)
at mrtjp.projectred.transmission.TWireCommons$class.onNeighborChanged(wireabstracts.scala:55)
at mrtjp.projectred.transmission.FramedWirePart.onNeighborChanged(wireabstracts.scala:318)
at codechicken.multipart.TileMultipart$$anonfun$onNeighborBlockChange$1.apply(TileMultipart.scala:165)
at codechicken.multipart.TileMultipart$$anonfun$onNeighborBlockChange$1.apply(TileMultipart.scala:165)
at codechicken.multipart.TileMultipart.operate(TileMultipart.scala:75)
at codechicken.multipart.TileMultipart.onNeighborBlockChange(TileMultipart.scala:165)
at codechicken.multipart.BlockMultipart.func_149695_a(BlockMultipart.scala:80)
at net.minecraft.world.World.func_147460_e(World.java:697)
at net.minecraft.world.World.func_147459_d(World.java:649)
at net.minecraft.world.World.func_147444_c(World.java:613)
at net.minecraft.world.World.markAndNotifyBlock(World.java:488)
at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:522)
at net.minecraft.item.ItemStack.func_77943_a(ItemStack.java:128)
at net.minecraft.server.management.ItemInWorldManager.func_73078_a(ItemInWorldManager.java:389)
at net.minecraft.network.NetHandlerPlayServer.func_147346_a(NetHandlerPlayServer.java:556)
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.func_148833_a(SourceFile:60)
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.func_148833_a(SourceFile:9)
at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:212)
at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:165)
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:659)
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:111)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)

Source block type: ID #0 (tile.air // net.minecraft.block.BlockAir)
Block type: ID #498 (tile.multipart // codechicken.multipart.BlockMultipart)
Block data value: 0 / 0x0 / 0b0000

commented

Will fix today.

commented

@Paul17041993 can you check if it still happens with the jars in #663?

commented

I'm not quite sure what's null here, @MrTJP can you help me find what's null:

    override def calcStraightArray(s:Int) =
    {
        WorldLib.getTileEntity(world, posOfStraight(s)) match
        {
            case ibe:IBundledEmitter => resolveArray(ibe, s^1)
            case t if t != null && APIImpl_Transmission.isValidInteractionFor(world, t.xCoord, t.yCoord, t.zCoord) =>
                resolveArray(t, s^1)
            case _ => super.calcStraightArray(s)
        }
    }

I added the t != null check, but I'm not sure it's feasible for t to be null there. That's the line number in the stack, but I don't know how match-case works.

commented

@Paul17041993 what version of PR are you running?

commented

major release 4.5.7.58 was what I was using, and the cables that would trigger the exception on an update could be seen pointing either to air or another block.

Ideally there should be a try-catch higher in the pipe so you can fire a reset or repair in the event of an errored tile/node, instead of letting it send the server into a crash loop...

Ill check the updated code to see if it works or not, but I believe it may have to be applied to the rest of the cabling as well...

commented

ok did more thorough testing and found the more direct cause, it occurs when the wire that was attached to a static wire is then moved across to be 'attached' to another block, and then crash, however it doesn't occur if the neighbor block is air, BUT in the patched (4.5.7.52) version no crash occurs and all cables are updating correctly

http://prntscr.com/5dq33r

Description: Exception while updating neighbours

java.lang.NullPointerException: Exception while updating neighbours
at mrtjp.projectred.transmission.FramedBundledCablePart.calcStraightArray(bundledwires.scala:258)
at mrtjp.projectred.transmission.FramedBundledCablePart$$anonfun$calculateSignal$2.apply(bundledwires.scala:247)
at mrtjp.projectred.transmission.FramedBundledCablePart$$anonfun$calculateSignal$2.apply(bundledwires.scala:246)
at scala.collection.immutable.Range.foreach(Range.scala:160)
at mrtjp.projectred.transmission.FramedBundledCablePart.calculateSignal(bundledwires.scala:246)
at mrtjp.projectred.transmission.TBundledCableCommons$class.updateAndPropagate(bundledwires.scala:89)
at mrtjp.projectred.transmission.FramedBundledCablePart.updateAndPropagate(bundledwires.scala:241)
at mrtjp.projectred.transmission.Propagation.go(propagation.scala:213)
at mrtjp.projectred.transmission.PropagationRun$$anonfun$runLoop$1.apply(propagation.scala:177)
at mrtjp.projectred.transmission.PropagationRun$$anonfun$runLoop$1.apply(propagation.scala:177)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1174)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at mrtjp.projectred.transmission.PropagationRun.runLoop(propagation.scala:177)
at mrtjp.projectred.transmission.PropagationRun.start(propagation.scala:155)
at mrtjp.projectred.transmission.WirePropagator$.propagateTo(propagation.scala:78)
at mrtjp.projectred.transmission.WirePropagator$.propagateTo(propagation.scala:84)
at mrtjp.projectred.transmission.TWireCommons$class.onNeighborChanged(wireabstracts.scala:55)
at mrtjp.projectred.transmission.FramedWirePart.onNeighborChanged(wireabstracts.scala:318)
at codechicken.multipart.TileMultipart$$anonfun$onNeighborBlockChange$1.apply(TileMultipart.scala:165)
at codechicken.multipart.TileMultipart$$anonfun$onNeighborBlockChange$1.apply(TileMultipart.scala:165)
at codechicken.multipart.TileMultipart.operate(TileMultipart.scala:75)
at codechicken.multipart.TileMultipart.onNeighborBlockChange(TileMultipart.scala:165)
at codechicken.multipart.BlockMultipart.func_149695_a(BlockMultipart.scala:80)
at net.minecraft.world.World.func_147460_e(World.java:697)
at net.minecraft.world.World.func_147459_d(World.java:648)
at net.minecraft.world.World.func_147444_c(World.java:613)
at com.rwtema.funkylocomotion.helper.BlockHelper.postUpdateBlock(BlockHelper.java:98)
at com.rwtema.funkylocomotion.movers.MoveManager.finishMoving(MoveManager.java:228)
at com.rwtema.funkylocomotion.blocks.TileMovingServer.func_145845_h(TileMovingServer.java:69)
at net.minecraft.world.World.func_72939_s(World.java:1939)
at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:489)
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:636)
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:111)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)

commented

Ignore my version numbers. Anything I give out is the latest off of Github. So, the patch works, correct?

commented

ok suddenly after going back to .58 to test more, it's only replicable when the movement is to the north and occurs with both framed and unframed bundle cable, but none of the insulated or primitive cable...

I cant rummage at the changes between .52 and .58 however as the repository stops at the 4.5.6 > 4.5.7 change and that's it, any succeeding changes are not actually on the public repository...

log, this time with non-framed bundle;
Description: Exception while updating neighbours

java.lang.NullPointerException: Exception while updating neighbours
at mrtjp.projectred.transmission.BundledCablePart.calcStraightArray(bundledwires.scala:234)
at mrtjp.projectred.transmission.BundledCablePart$$anonfun$calculateSignal$1.apply(bundledwires.scala:221)
at mrtjp.projectred.transmission.BundledCablePart$$anonfun$calculateSignal$1.apply(bundledwires.scala:216)
at scala.collection.immutable.Range.foreach(Range.scala:160)
at mrtjp.projectred.transmission.BundledCablePart.calculateSignal(bundledwires.scala:216)
at mrtjp.projectred.transmission.TBundledCableCommons$class.updateAndPropagate(bundledwires.scala:89)
at mrtjp.projectred.transmission.BundledCablePart.updateAndPropagate(bundledwires.scala:211)
at mrtjp.projectred.transmission.Propagation.go(propagation.scala:213)
at mrtjp.projectred.transmission.PropagationRun$$anonfun$runLoop$1.apply(propagation.scala:177)
at mrtjp.projectred.transmission.PropagationRun$$anonfun$runLoop$1.apply(propagation.scala:177)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1174)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at mrtjp.projectred.transmission.PropagationRun.runLoop(propagation.scala:177)
at mrtjp.projectred.transmission.PropagationRun.start(propagation.scala:155)
at mrtjp.projectred.transmission.WirePropagator$.propagateTo(propagation.scala:78)
at mrtjp.projectred.transmission.WirePropagator$.propagateTo(propagation.scala:84)
at mrtjp.projectred.transmission.TWireCommons$class.onNeighborChanged(wireabstracts.scala:55)
at mrtjp.projectred.transmission.WirePart.onNeighborChanged(wireabstracts.scala:204)
at codechicken.multipart.TileMultipart$$anonfun$onNeighborBlockChange$1.apply(TileMultipart.scala:165)
at codechicken.multipart.TileMultipart$$anonfun$onNeighborBlockChange$1.apply(TileMultipart.scala:165)
at codechicken.multipart.TileMultipart.operate(TileMultipart.scala:75)
at codechicken.multipart.TileMultipart.onNeighborBlockChange(TileMultipart.scala:165)
at codechicken.multipart.BlockMultipart.func_149695_a(BlockMultipart.scala:80)
at net.minecraft.world.World.func_147460_e(World.java:697)
at net.minecraft.world.World.func_147459_d(World.java:648)
at net.minecraft.world.World.func_147444_c(World.java:613)
at com.rwtema.funkylocomotion.helper.BlockHelper.postUpdateBlock(BlockHelper.java:98)
at com.rwtema.funkylocomotion.movers.MoveManager.finishMoving(MoveManager.java:228)
at com.rwtema.funkylocomotion.blocks.TileMovingServer.func_145845_h(TileMovingServer.java:69)
at net.minecraft.world.World.func_72939_s(World.java:1939)
at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:489)
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:636)
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:111)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)

commented

scratch that, I just realized the last number is the actual build number, the one you've provided is 4.5.2.52 and I'll be rummaging through the optimization changes...

commented

Again, IGNORE the build number! The thing I changed was #663, adding the missing null check that never existed. The jar provided is not .52, it is the current HEAD of my patch.

commented

aha, ok, its a random occurrence, I got a crash from unframed bundled cable moving southbound on your custom .52 build, but either way I cant get it to crash with the framed cable, so the null check is definitely there and will have to be replicated to all other cables, or the better solution may be to ensure t isn't null higher up in the pipe.

commented

yea apparently github has this thing of not showing replies until after you have posted yours...

commented

ok seems to only happen with the bundled types, coloured and bare cable, framed and unframed don't have the crash

commented

the better solution may be to ensure t isn't null higher up in the pipe.

Not possible, as t is literally created on the spot. I know what causes it, however, and I'll just go add the checks everywhere else.

commented

@Paul17041993 check #663, I updated the jars.

commented

yep, that's all the wires now behaving perfect with frame machinery, just like classic redpower...

looking at the changes now, the reason why the other cables didn't seem to have the crash was due to 'p:IPowerConnectable', I don't know scalar but from what I see it looks like a 'has this interface or parent' check, of which would likely just not be executed if it's null, whereas the bundled cables didn't have this, I could just be reading it wrong or it could be deeper then that, but its all working now is the main thing.