1548 posts
Location
That dark shadow under your bed...
Posted 25 January 2013 - 12:25 AM
this is an interesting bug I found while testing another one. basically if you place a computer, start it up and break it then it will keep running code until the next yield, I found this quite strange but it doesn't cause any serious issues EDIT: well the lag could be problematic I guess, didn't realize it never errored
to replicate the issue place a computer, place a monitor on top of it and add the startup file
local mon=peripheral.wrap("top")
local num=0
while true do
nunm=num+1
mon.clear()
mon.setCursorPos(1,1)
mon.write(num)
end
place a mining turtle in front of it and tell it to
peripheral.call("front","reboot") turtle.dig()
the computer turns on and is immediately broken but if you watch the monitor the number keeps counting up
EDIT: the "too long without yielding" error also never occurs. for some reason other computers still run when there is a computer never yielding but still it lags out the other computers until it gets a Java floating point error
Edited on 24 January 2013 - 11:29 PM
3790 posts
Location
Lincoln, Nebraska
Posted 25 January 2013 - 08:22 AM
So when there is no computer, it is still counting, or what? How long does it continue to count?
1548 posts
Location
That dark shadow under your bed...
Posted 25 January 2013 - 08:38 AM
So when there is no computer, it is still counting, or what?
yes that is exactly what happens
How long does it continue to count?
it keeps counting for quite a long time. it crashes at different times though (I think it is based on your available memory or something). about a full minute for me
3790 posts
Location
Lincoln, Nebraska
Posted 25 January 2013 - 08:40 AM
Wow…. I know monitors keep information displayed if another computer is attached, so is the turtle right next to the monitor as well? If so, try moving it away from the monitor and doing the same thing. That might help isolate the bug.
1548 posts
Location
That dark shadow under your bed...
Posted 25 January 2013 - 08:41 AM
the monitor is not touching the turtle at all. let me give you some screens. one minute
1548 posts
Location
That dark shadow under your bed...
Posted 25 January 2013 - 08:53 AM
ok here you go. it hasn't errored yet so I don't have a screen on that
Spoiler
THE STARTUP PROGRAM
THE BASIC SETUP
ONCE IT STARTS GOING
STILL GOING
since I restarted the PC and just launched MC rather than raping my PC with other games first it doesn't seem to stop… just keeps looping and you cannot even close the world normally, it just keeps trying to shutdown the internal server :(/>
EDIT: I had to add a sleep(0.5) before digging on the turtle this time, not sure why but it broke the PC after the struggling CC process allowed it to run a line of code
Edited on 25 January 2013 - 07:55 AM
3790 posts
Location
Lincoln, Nebraska
Posted 25 January 2013 - 09:02 AM
Just asking, but does it happen when breaking the computer with your fists or other tools? If not, then I bet you that it's because the turtle dug it. Definitely something to fix though.
1548 posts
Location
That dark shadow under your bed...
Posted 25 January 2013 - 09:04 AM
It also happens if I place the computer, start it up and break it manually, that's what I did before trying a sleep(0.5)
3790 posts
Location
Lincoln, Nebraska
Posted 25 January 2013 - 09:15 AM
Wow, that is certainly strange. Hopefully it gets fixed in the next version.
1548 posts
Location
That dark shadow under your bed...
Posted 25 January 2013 - 09:56 AM
After learning a little about how things work from those more knowledgeable than me I discovered that the os.shutdown() function is called when a computer is broken so I tried this
local cur=0
local sd=os.shutdown
local function nsd(...)
sd()
coroutine.yield()
end
repeat
cur=cur+1
local ok,t=pcall(function() return getfenv(cur) end)
if ok and rawget(t,"os") then rawset(rawget(t,"os"),"shutdown",nsd) end
until not ok
term.redirect(peripheral.wrap("top"))
local num=0
while true do
num=num+1
term.clear()
term.setCursorPos(1,1)
print(num)
end
but it still continued after breaking :(/>
392 posts
Location
Christchurch, New Zealand
Posted 25 January 2013 - 10:42 AM
The tile entity isn't being removed, I had this issue with MiscPeripherals, I wonder if it's something in CC or maybe a problem with MC all together. Apparently Forestry had a similar issue recently where the leaves would die but the TileEntity remained. Or maybe it's a common overlooked issue.
997 posts
Location
Wellington, New Zealand
Posted 25 January 2013 - 01:06 PM
The tile entity isn't being removed, I had this issue with MiscPeripherals, I wonder if it's something in CC or maybe a problem with MC all together. Apparently Forestry had a similar issue recently where the leaves would die but the TileEntity remained. Or maybe it's a common overlooked issue.
Since it stops as soon as the computer yields, I would think that it's still running on the CC thread because the "stop running this computer" message hasn't been received by that thread because it's busy running the computer's code… If that's the case though, it doesn't explain why other programs can still run.
392 posts
Location
Christchurch, New Zealand
Posted 25 January 2013 - 05:45 PM
Unless we have been mislead and each Computer does run in it's own Thread.. Which I always thought was the case, Because the Terminal Class has a ComputerThread class
1548 posts
Location
That dark shadow under your bed...
Posted 26 January 2013 - 01:44 AM
I have tested and managed to pause all other computers by stopping mine from yielding so they clearly do run one after another, this is the only instance I have seen of them still running (although very slowly)
try placing a turtle and giving it the startup file
while true do
turtle.forward()
turtle.back()
end
and start it up, it will move back and forth constantly
then place a computer and run the code
while true do print("BShere") end
and the turtle will stop moving until you get the "too long without yielding" error about 10 seconds later
392 posts
Location
Christchurch, New Zealand
Posted 28 January 2013 - 10:01 AM
That means there is only one event queue, or the event queue is static ( same thing really )
Do a while loop of two computers printing BShere, do they both print at the same time?
Use a monitor to be sure :)/>
8543 posts
Posted 31 January 2013 - 03:48 AM
All computers are coroutines in a single Lua interpreter. As you already know, only one coroutine is running at any given point in time.