MightyPirates / TIS-3D

TIS-100 inspired low-tech computing in Minecraft.
https://www.curseforge.com/minecraft/mc-mods/tis-3d
Other
108 stars 35 forks source link

Dividing by zero crashes Minecraft #70

Closed josephcsible closed 6 years ago

josephcsible commented 6 years ago

Running the instruction "DIV 0" causes Minecraft to crash. Stack trace:

java.lang.ArithmeticException: / by zero
    at li.cil.tis3d.common.module.execution.instruction.InstructionDivImmediate.step(InstructionDivImmediate.java:16)
    at li.cil.tis3d.common.module.execution.MachineImpl.step(MachineImpl.java:62)
    at li.cil.tis3d.common.module.ModuleExecution.step(ModuleExecution.java:109)
    at li.cil.tis3d.common.machine.CasingImpl.stepModules(CasingImpl.java:119)
    at li.cil.tis3d.common.tileentity.TileEntityCasing.stepModules(TileEntityCasing.java:221)
    at li.cil.tis3d.common.tileentity.TileEntityController$$Lambda$240/952321792.accept(Unknown Source)
    at java.util.ArrayList.forEach(ArrayList.java:1249)
    at li.cil.tis3d.common.tileentity.TileEntityController.step(TileEntityController.java:520)
    at li.cil.tis3d.common.tileentity.TileEntityController.func_73660_a(TileEntityController.java:358)
    at net.minecraft.world.World.func_72939_s(World.java:1811)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:614)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:765)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:666)
    at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:185)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524)
    at java.lang.Thread.run(Thread.java:745)

Tested on Minecraft 1.12.1, Forge 14.22.1.2484, and TIS-3D 1.2.3.7.

payonel commented 6 years ago

this is expected behavior /s

Techokami commented 6 years ago

On one hand, yes. On the other hand, this can be used as a DoS vector, so there should be something to catch this in the mod and perform a proper response in-game. Like having the module explode or give an error somewhere.

fnuecke commented 6 years ago

HAHAHAHAHA. Oh wow. How did I not run into this before. Yeah, this should definitely result in a HCF instead.