This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Kane Hart's profile picture

[MAJOR] ComputerCraft Threads don't close on chunk unload.

Started by Kane Hart, 06 March 2012 - 10:15 PM
Kane Hart #1
Posted 06 March 2012 - 11:15 PM
Today I found out my Linux box was being raped hard by memory errors from every application on the box that spawns extra threads. Mainly my MC Servers. What ended up happening is ComputerCraft had failed and capped ou the max amount of threads open by the OS None Default Settings that I had already quadrupled.


So how do you repeat this? Simple, Move 200 blocks away from spawn mainly because spawn area does not unload chunks or at least in SMP I'm unsure about SSP. Setup 10 computers and leave the area and come back many many times. You will make your computer cry. So what is actually happening? The LUA engine I guess would be an okay term to use is not shutting down period. It stays open and rather then even using the ones that are already open it goes back and opens new ones over and over.

I'm no programmer but I did a small thread dump of many examples. I suggest you check out the last one to give you an idea of 10 reloggins on a SMP Server that is Vanilla just using MLMP/Forge/CC AND NOTHING ELSE!


6 Thread Dumps:
1) fresh login
http://godcraft.com/x/ccdump1.txt

2) 10 pc's placed and turned on
http://godcraft.com/x/ccdump2.txt

3) logged out waited 60 seconds and dump
http://godcraft.com/x/ccdump3.txt

4) logged in again and 77 live threads.
http://godcraft.com/x/ccdump4.txt

5) 5 relogins 225 live threads while not logged in.
http://godcraft.com/x/ccdump5.txt

6) 10 relogins 375 live threads OMFG!
http://godcraft.com/x/ccdump6.txt


My suggestion would be to consider halting any new updates for ComputerCraft until this problem gets resolved, since this is actually something that can be very dangerous for server owners and even the hardcore SSP players.

Super_Random #2
Posted 06 March 2012 - 11:41 PM
Seems bad…
Cloudy #3
Posted 06 March 2012 - 11:45 PM
My suggestion would be to consider halting any new updates for ComputerCraft until this problem gets resolved, since this is actually something that can be very dangerous for server owners and even the hardcore SSP players.

I disagree that any updates should be postponed; especially since 1.31 is almost ready - it will take a while for people to port it to bukkit what most server owners use anyway. I also very much doubt it will cause any issue for SSP players. However, I do agree that it is probably should be a priority to get it fixed, if possible.
FuzzyPurp #4
Posted 06 March 2012 - 11:58 PM
Woah.
Kane Hart #5
Posted 07 March 2012 - 12:03 AM
My suggestion would be to consider halting any new updates for ComputerCraft until this problem gets resolved, since this is actually something that can be very dangerous for server owners and even the hardcore SSP players.

I disagree that any updates should be postponed; especially since 1.31 is almost ready - it will take a while for people to port it to bukkit what most server owners use anyway. I also very much doubt it will cause any issue for SSP players. However, I do agree that it is probably should be a priority to get it fixed, if possible.

Sorry It's personal preference <3 I guess I should have said that more. I personally can't use it period and I feel like we could do so much for CC overtime and including doing a lot of cool videos in a larger SMP environment. But this has really broken my heart.
Cloudy #6
Posted 07 March 2012 - 09:00 PM
To give my understanding from what Casper said earlier and what I know:

It seems in its current form (the build you're using) LuaJ doesn't look after itself and clear the threads made by the coroutine LuaThread. Casper compiled the build from the LuaJ CVS - which seems to destroy any threads which the user create (can test by creating a blank coroutine).

However, it seems that ComputerCraft still leaves three Java threads open per computer - even if the computer is shut down. Most likely this is LuaJ leaving the threads open after you've even set the coroutine to nil - maybe there is still a reference to the coroutine somewhere as it only gets rid of coroutines which no longer have a Lua reference.

As for the source of the three threads - two coroutines are created during bios.lua as it runs rednet in tandem with the shell, and I'd assume the third thread is the one for the computer itself.
Hawk777 #7
Posted 08 March 2012 - 10:53 AM
I already pointed this out, along with the fact that there's a much easier way to hit the bug than walking in and out of chunk load distance:

http://www.computercraft.info/forums2/index.php?/topic/340-13-infinite-threads/
FuzzyPurp #8
Posted 15 March 2012 - 07:30 PM
:D/>/> so CC is basically no bueno for smp. In this current state of LuaJ