What exactly is Stackoverflow?

Find quick help here to get you started with Hollywood
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

What exactly is Stackoverflow?

Post 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.
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: What exactly is Stackoverflow?

Post by SamuraiCrow »

What is the stack size set to in the icon info?
I'm on registered MorphOS using FlowStudio.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: What exactly is Stackoverflow?

Post 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.
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: What exactly is Stackoverflow?

Post 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:
I'm on registered MorphOS using FlowStudio.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: What exactly is Stackoverflow?

Post 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.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: What exactly is Stackoverflow?

Post 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=""}
              }
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: What exactly is Stackoverflow?

Post by airsoftsoftwair »

It's very likely a bug in your code, like some recursion gone wrong.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: What exactly is Stackoverflow?

Post 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.
User avatar
jPV
Posts: 600
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: What exactly is Stackoverflow?

Post by jPV »

Are you sure you're not calling some functions recursively "deeper and deeper" without them returning first?
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: What exactly is Stackoverflow?

Post 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.
I'm on registered MorphOS using FlowStudio.
Post Reply