Page 1 of 2

What exactly is Stackoverflow?

Posted: Tue Jun 26, 2018 9:59 pm
by Bugala
I am having trouble with Stack overflow and I dont know where to look for the problem.

Thing is, I made a build of my game, and it works fine when i test it. However, another who tried it said that he gets Stack Overflow during the game.
First time at level 3, and then after that he have started getting it at levels 1 and 2 already, not getting even to the 3 anymore.
That would sound like something stays even after the program have crash exited already.

Re: What exactly is Stackoverflow?

Posted: Tue Jun 26, 2018 10:19 pm
by SamuraiCrow
What is the stack size set to in the icon info?

Re: What exactly is Stackoverflow?

Posted: Tue Jun 26, 2018 11:10 pm
by airsoftsoftwair
I guess he means a stack overflow within Hollywood's virtual machine. It happens when the stack overflows, i.e. when there are too many elements on the stack, e.g. during a function that repeatedly recurses and pushes parameters on the stack.

Re: What exactly is Stackoverflow?

Posted: Tue Jun 26, 2018 11:16 pm
by SamuraiCrow
Sorry, I gave you the solution without first answering the question. The stack is where all local variables and function return addresses are stored.

Also, if you run your Hollywood script from a CLI, the script gets the CLI stack allocation size set by the AmigaDOS stack command. If you run from Workbench it allocates a new stack set by the size listed in the icon. If that weren't complex enough, AmigaOS 4.x can use a "stack cookie" to replace the other approaches. :geek:

Re: What exactly is Stackoverflow?

Posted: Tue Jun 26, 2018 11:33 pm
by Bugala
Okay, thanks, this helps.

My best case is it has to do with my big table that has functions and other parts of the same table stored in it, it is a terrible mess. I just made a version which keeps loading pieces from files, maybe that corrects it.

Re: What exactly is Stackoverflow?

Posted: Wed Jun 27, 2018 10:56 am
by Bugala
I Got error produced by that other user and StackOverflow happens on following 3 lines:

Code: Select all

For n = 0 To ListItems(T_Code)-1
	If HaveItem(T_Code[n], "text") And T_Code[n].text = Labelname Then foundn = n
Next
Error indicates it would be the first line of those three, hence I am suspecting it is caused by ListItems command.

Strange thing is, that the Table it is doing the List Items should be about following: (I checked this with debugprint, but of course cant be exactly sure what he did, but this should be it based upon where it crashes)

Code: Select all

T_Code = {random = 0, CurrentLine=unknown number, 
			[0] = {command="GO TO", text="Go To <MAIN>", Indent="   "}
			[1] = {command="Move Forward", text="Move Forward", indent="   "}
			[2] = {command="Add Label", text="MAIN", indent=""}
              }

Re: What exactly is Stackoverflow?

Posted: Thu Jun 28, 2018 6:33 pm
by airsoftsoftwair
It's very likely a bug in your code, like some recursion gone wrong.

Re: What exactly is Stackoverflow?

Posted: Thu Jun 28, 2018 11:09 pm
by Bugala
By the way, i changed the ListItems() command to TableItems() and he got stackoverflow on different place and only once anymore.

So it seems it really has to do with the listitems command somehow.

Dont know if issue got fixed now that i recompiled it using 7.1 as the one who was playing it, already got through the game, so i doubt he will be using the newly compiled version.

Re: What exactly is Stackoverflow?

Posted: Fri Jun 29, 2018 7:18 am
by jPV
Are you sure you're not calling some functions recursively "deeper and deeper" without them returning first?

Re: What exactly is Stackoverflow?

Posted: Fri Jun 29, 2018 9:54 am
by SamuraiCrow
As an off topic aside note, it's quicker to use a reverse lookup table to indicate which item in T_Code is indicated. Linear searches are more expensive.