Jump to content




Quarry turtle and Tree farm turtle both go too long without yielding, can't find cause

turtle help

  • You cannot reply to this topic
10 replies to this topic

#1 Bab

  • Members
  • 61 posts

Posted 16 January 2014 - 05:40 AM

Hello people,

I've been busying myself making programs for computercraft for a couple of months now, but in two of my programs there seems to be a bug that I cannot squash.
I have a network set up with a central host computer displaying the status of all turtles attached to it via wireless modems, both on a screen and on OpenPeripherals' Terminal Glasses. This works fine.
However, two of the turtles attached to it, which run 24/7, crash after an undetermined amount of time because they went on too long without yielding.
The error never drops a line and wipes the file the turtles use to keep their progress.
The two programs can be found here:
Quarry:
http://pastebin.com/8wZjexV3
Tree Farm:
http://pastebin.com/pYtcjytq

If I made a really dumb mistake then I'm sorry for wasting your time.
If not, please help me out!

#2 karelmikie3

  • Members
  • 112 posts

Posted 16 January 2014 - 01:36 PM

did you miss a sleep in the quarry and/of ping function, i don't have time to check the code right now, just a surgestion

#3 Bab

  • Members
  • 61 posts

Posted 16 January 2014 - 05:06 PM

There are sleep(0)'s in every single loop, I checked it multiple times.

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 16 January 2014 - 06:07 PM

They're not in every loop. They're also not necessary in most of the loops, if they're even necessary in any of them. These programs are designed rather oddly.

#5 Bab

  • Members
  • 61 posts

Posted 17 January 2014 - 12:58 AM

Oddly in what way? If you mean the way the whole thing loops, it's kind of an artifact from a long time ago when I first wrote it to be compatible with my server program, as the main function couldn't be executed for long.
Even so, I still don't understand why it crashes for not yielding if they do yield when necessary.

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 17 January 2014 - 01:32 AM

An excessively low tick rate server can cause it, or a slow computer if playing singleplayer.

#7 Bab

  • Members
  • 61 posts

Posted 17 January 2014 - 04:20 AM

I host the server on my own gaming computer, running a tweaked FTB Unleashed with GregTech. I very rarely, if at all, get messages about the server not keeping up, nor do I get lag while playing. Is there an easy way to see if I cross that limit?

Edit: by the way, they don't crash at the same time; most of the time, one crashes while the other works as it should.

Edit 2: The tree farm turtle managed to kill the main thread of computercraft, taking several completely unrelated turtles down with it. What did I do?

As I couldn't find any rule against thread bumping...
Bump.

Edited by Lyqyd, 20 January 2014 - 07:41 PM.


#8 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 20 January 2014 - 06:23 PM

Maybe there is recursive calling in ping() or treefarm(). Don't have enough time to analyse the code, sorry...

#9 Bab

  • Members
  • 61 posts

Posted 21 January 2014 - 06:17 AM

No, I'm not calling ping(), treeFarm() or any other function in itself. Thanks for the suggestion though.
Thing is, it works for hours on end when it suddenly decides to stop.

#10 CoLDarkness

  • Members
  • 53 posts
  • LocationVoid

Posted 21 January 2014 - 07:43 AM

View PostFreack100, on 20 January 2014 - 06:23 PM, said:

Don't have enough time to analyse the code, sorry...
^
This occured to me once.

Make sure you put sleep(0) in the loops and make sure they are positioned like this:

while true do
-- Code
-- Code
-- Something else
AnotherResourceConsumingHugeLoop()
sleep(0)
-- code
-- code
-- code
end

This is how I fixed it.

#11 Bab

  • Members
  • 61 posts

Posted 21 January 2014 - 09:02 AM

I just went through all loops in the program, couldn't find any of those cases.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users