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

I Broke It

Started by interfect, 28 February 2012 - 10:21 AM
interfect #1
Posted 28 February 2012 - 11:21 AM
I can reliably kill CC 1.3 with a "vm error: java.lang.ArrayIndexOutOfBoundsException", followed by "nil: thread: java.lang.ThreadDeath". These two things print on the screen of my turtle, and I have to reboot it.

Steps to reproduce:

1. Install my "nav" and "navTest" scripts from cc-get onto a turtle. I'm not sure about the paths, but navTest has to be able to os.loadAPI("nav").
2. Run navTest.
3. The turtle should start trying to move between random places within a relatively small area and its original location. It is supposed to do this forever, pathing around any blocks that may be in the way using A* pathfinding. Unfortunately, after running for a couple of minutes I get this Java error deep in my A* code (where it's naievely scanning the open list for the best node, but possibly elsewhere also).

The errors will reference lines in my Lua code, but the references don't really make sense (once the line was "end"). Since it looks like an internal Java error, I'm calling this a ComputerCraft bug. If my code is buggy, I should be getting Lua errors rather than Java errors. If not, ComputerCraft should be executing it properly.

Is this the right place to report bugs? If not, where is?
Espen #2
Posted 28 February 2012 - 12:12 PM
Is this the right place to report bugs? If not, where is?
Because it's not really a question per se, but rather a report, I'd personally suggest to post such things in the General-Section.
It's also a good idea to tag your title with something like [Bug] and maybe even the severity of the bug, like [Minor] or something like that.
That's just my personal suggestion, since you asked.
MysticT #3
Posted 28 February 2012 - 12:48 PM
I'm not sure about this, but i think the problem is with the stack. This happened to me once, and it was because of a recursive function, wich called itself forever, thus causing a stack overflow (wich you see as a java error).
So if you have a recursive function, try to make it not call itself forever, or at least, if you have to do it, do something like this:

function someFunc()
	doSomething()
	return someFunc()
end
When you do "return (your function)()", lua reuses the stack.
Taken from the lua manual:
A call of the form return functioncall is called a tail call. Lua implements proper tail calls (or proper tail recursion): in a tail call, the called function reuses the stack entry of the calling function. Therefore, there is no limit on the number of nested tail calls that a program can execute. However, a tail call erases any debug information about the calling function. Note that a tail call only happens with a particular syntax, where the return has one single function call as argument; this syntax makes the calling function return exactly the returns of the called function. So, none of the following examples are tail calls:
return (f(x)) – results adjusted to 1
return 2 * f(x)
return x, f(x) – additional results
f(x); return – results discarded
return x or f(x) – results adjusted to 1
interfect #4
Posted 28 February 2012 - 10:24 PM
I'm not using anything recursive, but an out-of-memory error is potentially possible, depending on how limited the Lua memory space is. I'm not putting anything really large on the stack (just short strings and small tables), and again there's no recursion, so I bet against stack overflow.
Advert #5
Posted 28 February 2012 - 11:35 PM

vm error: java.lang.ArrayIndexOutOfBoundsException: 256

Is the error you'll get when you run out of stack space.

Out of memory would be a different error; and would probably cause minecraft to crash, as Lua's memory usage in CC isn't limited.

Mind posting which line #s it was erroring at? Sometimes the error happens near the line, and not on it.
interfect #6
Posted 29 February 2012 - 04:40 AM
Mind posting which line #s it was erroring at? Sometimes the error happens near the line, and not on it.

I just tried it again, and got the ArrayIndexOutOfBoundsException on line 86 of shell, and the ThreadDeath on line 283 of rednet. Something I'm doing is corrupting the Lua interpreter's internal state, I think.
FuzzyPurp #7
Posted 29 February 2012 - 04:55 AM
Like i suggested to Casper, the Forums needs a few more sections, but he disagrees. I can see this forum getting pretty bloated and unorganized with a few weeks/months. Then i wont even bother to read half this stuff.
Casper7526 #8
Posted 29 February 2012 - 05:30 AM
Just for fun I'll add a bugs and suggestions forum tomorrow, you'll see why I disagree real quick.
FuzzyPurp #9
Posted 29 February 2012 - 06:18 AM
Just for fun I'll add a bugs and suggestions forum tomorrow, you'll see why I disagree real quick.

Rules/Format for reporting bugs, lock/delete all bugs related to bukkit. They have their own forum for that.