CC: Tweaked

CC: Tweaked

57M Downloads

Mount/unmount leaking file objects

LemADEC opened this issue ยท 5 comments

commented

Useful information to include:

  • Minecraft version 1.12.2
  • CC: Tweaked version 1.80pr1.13
  • Detailed reproduction steps!

When attaching computer controlled blocks to a computer, my mod is also mounting different preloaded scripts as resources.
When detaching the computer, my mod asks to dismount them.
For some obscure reason, on our server, it fails to unmount them with this callstack:

[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: java.lang.IllegalStateException: You didn't mount this location
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.apis.ComputerAccess.unmount(ComputerAccess.java:110)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.unmount(PeripheralAPI.java:155)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at cr0s.warpdrive.block.TileEntityAbstractInterfaced.CC_unmount(TileEntityAbstractInterfaced.java:479)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at cr0s.warpdrive.block.TileEntityAbstractInterfaced.detach(TileEntityAbstractInterfaced.java:496)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at pl.asie.computronics.api.multiperipheral.WrappedMultiPeripheral.detach(WrappedMultiPeripheral.java:48)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at pl.asie.computronics.cc.multiperipheral.MultiPeripheral.detach(MultiPeripheral.java:114)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.detach(PeripheralAPI.java:92)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.apis.PeripheralAPI.shutdown(PeripheralAPI.java:363)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.computer.Computer$2.execute(Computer.java:910)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.computer.ComputerThread$TaskRunner.run(ComputerThread.java:284)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at java.lang.Thread.run(Thread.java:748)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: java.lang.IllegalStateException: You didn't mount this location
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.apis.ComputerAccess.unmount(ComputerAccess.java:110)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.unmount(PeripheralAPI.java:155)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at cr0s.warpdrive.block.TileEntityAbstractInterfaced.CC_unmount(TileEntityAbstractInterfaced.java:479)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at cr0s.warpdrive.block.TileEntityAbstractInterfaced.detach(TileEntityAbstractInterfaced.java:496)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at pl.asie.computronics.api.multiperipheral.WrappedMultiPeripheral.detach(WrappedMultiPeripheral.java:48)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at pl.asie.computronics.cc.multiperipheral.MultiPeripheral.detach(MultiPeripheral.java:114)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.detach(PeripheralAPI.java:92)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.apis.PeripheralAPI.shutdown(PeripheralAPI.java:363)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.computer.Computer$2.execute(Computer.java:910)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at dan200.computercraft.core.computer.ComputerThread$TaskRunner.run(ComputerThread.java:284)
[12:04:54] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_unmount:483]: 	at java.lang.Thread.run(Thread.java:748)
[12:04:54] [ComputerCraft-Computer-Runner-0/ERROR] [warpdrive]: Failed to unmount ComputerCraft scripts for warpdriveShipCore @ solarSystem (-42122 140 29036), isFirstTick false

I'm not able to reproduce in single player with just CC-tweaked and Computronics. So, I'm probably missing something.
Any idea on what could be triggering this?

Furthermore, after some time, the mount fails due to 'Too many open files', which means there's a leak. I suspect the unmounting didn't happen properly, and also, CC doesn't cache the RessourceMount, hence constantly creating new ones?

[15:57:11] [Server thread/ERROR] [warpdrive]: Failed to mount ComputerCraft scripts for warpdriveMiningLaser @ solarSystem (-42213 134 28878), isFirstTick false
[15:57:11] [Server thread/ERROR] [computercraft]: Could not load mount from mod jar
java.nio.file.FileSystemException: /home/tucker19/./mods/WarpDrive-1.12.2-1.5.0.-2019-01-13a.jar: Too many open files
>       at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91) ~[?:1.8.0_191]
>       at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:1.8.0_191]
>       at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:1.8.0_191]
>       at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) ~[?:1.8.0_191]
>       at java.nio.file.Files.newByteChannel(Files.java:361) ~[?:1.8.0_191]
>       at java.nio.file.Files.newByteChannel(Files.java:407) ~[?:1.8.0_191]
>       at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:129) ~[zipfs.jar:1.8.0_191]
>       at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:139) ~[zipfs.jar:1.8.0_191]
>       at java.nio.file.FileSystems.newFileSystem(FileSystems.java:390) ~[?:1.8.0_191]
>       at dan200.computercraft.ComputerCraft.createResourceMount(ComputerCraft.java:499) [ComputerCraft.class:?]
>       at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source) ~[?:?]
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
>       at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
>       at dan200.computercraft.api.ComputerCraftAPI.createResourceMount(ComputerCraftAPI.java:162) [ComputerCraftAPI.class:?]
>       at cr0s.warpdrive.block.TileEntityAbstractInterfaced.CC_mount(TileEntityAbstractInterfaced.java:490) [TileEntityAbstractInterfaced.class:?]
>       at cr0s.warpdrive.block.TileEntityAbstractInterfaced.CC_mount(TileEntityAbstractInterfaced.java:468) [TileEntityAbstractInterfaced.class:?]
>       at cr0s.warpdrive.block.TileEntityAbstractInterfaced.attach(TileEntityAbstractInterfaced.java:453) [TileEntityAbstractInterfaced.class:?]
>       at pl.asie.computronics.api.multiperipheral.WrappedMultiPeripheral.attach(WrappedMultiPeripheral.java:43) [WrappedMultiPeripheral.class:?]
>       at pl.asie.computronics.cc.multiperipheral.MultiPeripheral.attach(MultiPeripheral.java:107) [MultiPeripheral.class:?]
>       at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral$RemotePeripheralWrapper.attach(WiredModemPeripheral.java:305) [WiredModemPeripheral$RemotePeripheralWrapper.class:?]
>       at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral.attachPeripheralImpl(WiredModemPeripheral.java:252) [WiredModemPeripheral.class:?]
>       at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral.attachPeripheral(WiredModemPeripheral.java:228) [WiredModemPeripheral.class:?]
>       at dan200.computercraft.shared.peripheral.modem.wired.TileCable$CableElement.attachPeripheral(TileCable.java:69) [TileCable$CableElement.class:?]
>       at dan200.computercraft.shared.peripheral.modem.wired.WiredModemElement.networkChanged(WiredModemElement.java:51) [WiredModemElement.class:?]
>       at dan200.computercraft.shared.wired.WiredNetworkChange.broadcast(WiredNetworkChange.java:112) [WiredNetworkChange.class:?]
>       at dan200.computercraft.shared.wired.WiredNetwork.connect(WiredNetwork.java:86) [WiredNetwork.class:?]
>       at dan200.computercraft.api.network.wired.IWiredNode.connectTo(IWiredNode.java:61) [IWiredNode.class:?]
>       at dan200.computercraft.shared.peripheral.modem.wired.TileCable.connectionsChanged(TileCable.java:378) [TileCable.class:?]
>       at dan200.computercraft.shared.peripheral.modem.wired.TileCable.func_73660_a(TileCable.java:350) [TileCable.class:?]
>       at org.spongepowered.common.event.tracking.TrackingUtil.tickTileEntity(TrackingUtil.java:228) [TrackingUtil.class:1.12.2-2768-7.1.5-RC3522]
>       at net.minecraft.world.WorldServer.updateTileEntity(WorldServer.java:3470) [oo.class:?]
>       at net.minecraft.world.WorldServer.redirect$onUpdateTileEntities$zmo000(WorldServer.java:3457) [oo.class:?]
>       at net.minecraft.world.World.func_72939_s(World.java:7656) [amu.class:?]
>       at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:2795) [oo.class:?]
>       at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:767) [MinecraftServer.class:?]
>       at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397) [nz.class:?]
>       at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?]
>       at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
>       at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]: java.lang.NullPointerException: mount cannot be null
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at java.util.Objects.requireNonNull(Objects.java:228)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.core.apis.ComputerAccess.mount(ComputerAccess.java:48)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.mount(PeripheralAPI.java:133)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral$RemotePeripheralWrapper.mount(WiredModemPeripheral.java:340)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at cr0s.warpdrive.block.TileEntityAbstractInterfaced.CC_mount(TileEntityAbstractInterfaced.java:492)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at cr0s.warpdrive.block.TileEntityAbstractInterfaced.CC_mount(TileEntityAbstractInterfaced.java:468)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at cr0s.warpdrive.block.TileEntityAbstractInterfaced.attach(TileEntityAbstractInterfaced.java:453)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at pl.asie.computronics.api.multiperipheral.WrappedMultiPeripheral.attach(WrappedMultiPeripheral.java:43)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at pl.asie.computronics.cc.multiperipheral.MultiPeripheral.attach(MultiPeripheral.java:107)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral$RemotePeripheralWrapper.attach(WiredModemPeripheral.java:305)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral.attachPeripheralImpl(WiredModemPeripheral.java:252)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral.attachPeripheral(WiredModemPeripheral.java:228)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.peripheral.modem.wired.TileCable$CableElement.attachPeripheral(TileCable.java:69)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.peripheral.modem.wired.WiredModemElement.networkChanged(WiredModemElement.java:51)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.wired.WiredNetworkChange.broadcast(WiredNetworkChange.java:112)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.wired.WiredNetwork.connect(WiredNetwork.java:86)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.api.network.wired.IWiredNode.connectTo(IWiredNode.java:61)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.peripheral.modem.wired.TileCable.connectionsChanged(TileCable.java:378)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at dan200.computercraft.shared.peripheral.modem.wired.TileCable.func_73660_a(TileCable.java:350)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at org.spongepowered.common.event.tracking.TrackingUtil.tickTileEntity(TrackingUtil.java:228)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at net.minecraft.world.WorldServer.updateTileEntity(WorldServer.java:3470)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at net.minecraft.world.WorldServer.redirect$onUpdateTileEntities$zmo000(WorldServer.java:3457)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at net.minecraft.world.World.func_72939_s(World.java:7656)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:2795)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:767)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
[15:57:11] [Server thread/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:CC_mount:479]:     at java.lang.Thread.run(Thread.java:748)

Here's my existing code for mounting a file or folder:

final IMount mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.class, WarpDrive.MODID, pathAsset);
computerAccess.mount(pathLUA, mountCommon);

I can add a cache there, but that seems weird when CC on 1.7.10 never had such a resource leak on a busy server, so it feels like a regression somewhere.

commented

With the You didn't mount this location error, can you try with multiple peripherals attached to one computer? Normally this only occurs if you try to unmount something which somebody mounted, or the original mounting failed - also check your .mount calls don't return null!

WRT the Too many open files error, ideally you should be caching the mounts on your end, as they're not super-cheap to construct (we scan that folder/file of the zip directory to find all files). However, CC:T is also definitely failing to clean up some resources, so I'll look into that.

commented

1- I've added a cache and a quick fix for the actual mount location.
On the server, we don't have 2 blocks connecting to the same computer. So I'm still a bit confused on what's causing the unmount() error.

2- ok

3- I've tried to connect the same peripheral several times to the same computer using wired modems:

  • with a disk drive, I see the LUA path gets updated dynamically to disk, disk2, disk3.
  • with my ShuttleCore block, the LUA path fails (mount() is returning null) instead of relocating. Is it intended to only relocate for writable mounts?
commented

Is it intended to only relocate for writable mounts?

It hasn't relocated automatically for a while now, though I'd need to check when that was changed (1.7.10 maybe?). You'll need to do that on your end.

commented

3- 1.7.10 didn't relocate either. At that time, I had already added a secondary location in case the startup script was already present for whatever reason.

commented

1- I've found why we have 2 blocks connecting to the same computer, hence trying to unmount multiple time the same location.

So the rest is all yours to fix :)