Jump to content
  • Advertisement
Sign in to follow this  

Trouble with Lua Stack overflows

This topic is 813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using C#, NLua and SFML.net.


I have a lua script which is causing Stack Overflow exceptions... but I am not recursing in anyway...


Here is the lua script:




function OnCollider(sysman, ent1, ent2)
   if (sysman:LUAHasComponent('EntranceComponent',ent2)) then
sysman:LogToConsole('Bumped into an Entrance');
if  eComp.Coords=='' then
   sysman:LogToConsole("Empty cords. Go up a level.");
 sysman:LogToConsole('Creating dungeon tilemap');
   -- sysman:LogToConsole(eComp.Coords .. "abc" .. "QRD");
 nxtCord=eComp.Coords .. ":[";
 nxtCord=nxtCord .. pLoc.TileLocation.X;
 nxtCord=nxtCord .. ",";
 nxtCord=nxtCord .. pLoc.TileLocation.Y;
    --sysman:LogToConsole(eComp.Coords .. ":[" .. (pLoc.TileLocation.X) .. "," .. (pLoc.TileLocation.Y));
 --sysman:LogToConsole --..","..pLoc.TileLocation.Y.."]");
   if (depth==1) then
   sysman:LogToConsole('Creating GlobalTilemap');
if (depth==2) then 
   sysman:LogToConsole('Creating LocalTilemap');
if (depth>2) then 
   sysman:LogToConsole('Creating MinimalTilemap');
sysman:LogToConsole('Setting run result');
   request = Request.CreateRequest('ActionInput',ent1, actionData);
  --r.Visible=not r.Visible;


The  exception occurs when this bit of script is ran (I will number these lines)

1  sysman:LogToConsole('Creating dungeon tilemap');
 -- sysman:LogToConsole(eComp.Coords .. "abc" .. "QRD");
3 pLoc=sysman:LUAGetComponent('LocationComponent',ent1);
5 nxtCord=eComp.Coords .. ":[";
6 nxtCord=nxtCord .. pLoc.TileLocation.X;
7 nxtCord=nxtCord .. ",";
8 nxtCord=nxtCord .. pLoc.TileLocation.Y;
9 sysman:LogToConsole(nxtCord);
10 --sysman:LogToConsole(pLoc.TileLocation.Y);
 11   --sysman:LogToConsole(eComp.Coords .. ":[" .. (pLoc.TileLocation.X) .. "," .. (pLoc.TileLocation.Y));
Ok, I I comment out line 8 I do not get an overflow exception.
If I Comment out line 8 and replace line 6 with line 8 I do not get an overflow exception...
LUGGetComponent returns a struct with a set of members, one of which is TileLocation. TileLocation is a sfml Vector2i with two public members X and Y 

Share this post

Link to post
Share on other sites

Blowing your stack can be messy. :-)


If it isn't recursion, the next thing to check is large amounts of data on the stack.  


Look for large arrays or buffers or similar, basically looking at all the local variables in the stack trace.  If you've got arrays of several thousand items or some multidimensional arrays, both can consume your stack.


Sometimes in optimized builds, inlined functions with large stack use can also trigger blowing the stack.  


Global variables can also sometimes use stack space, but generally don't; even so, look for large static items and clean them up while you are at it.

Edited by frob

Share this post

Link to post
Share on other sites

Also, check that the C-functions you use pop everything they push temporarily and the amount of return values you return matches the amount you pushed.

Edited by DaBono

Share this post

Link to post
Share on other sites

Thanks for the help. It turns out there was a bug in SFML... it had gotten fixed about two years ago but i Guess the fix never made it to the version hosted on sfml's site...


Got the source from git hub, rebuilt and everything is good to go. Thanks again.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!