Jump to content

Stack overflow


[DMC]

Recommended Posts

Posted

hey,

i got a script for the admins when i do /admins it says

Level 10=

level 9=

etc

but when i do this its saying stack overflow :mrgreen:

im not comfortable with posting this

so im just asking what this error means :|

logo_left.png
Posted

That the stack has overflown. I've only ever reproduced this by calling a function from within itself, like;

function a() a() end 

Retired

Posted

callum, i have seen his code if i'm right he is doing that :P

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
hey,

i got a script for the admins when i do /admins it says

Level 10=

level 9=

etc

but when i do this its saying stack overflow :mrgreen:

im not comfortable with posting this

so im just asking what this error means :|

there are at lest two ways to prevent this:

1) Proper Tail Call

function a()  
 return a()  
end 

Because a proper tail call uses no stack space, there is no limit on the number of "nested" tail calls that a program can make. For instance, we can call the following function with any number as argument; it will never overflow the stack.

2) setTimer function

function a()  
 setTimer (a,50,1)  
end 

i always use "setTimer" method myself, ofcourse the interval may be difrent than 50 (50 is minimum)

Posted

infinite loop/infinite recursion causes this.

Wojak:

  
-- this is infinite recursion too !! and will trigger stack overflow 
function a()  
 return a()  
end 
  

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

i was bored in the work one day and i read the lua manual...

this expresion

function a() 
  return a() 
end 

is a "Proper Tail Cal" and lua interpreter treats it like "GoTo" and do not use any stack space. No stack -> no stack overflow

http://www.lua.org/pil/6.3.html

of course every scripter should know how to prevent Infinite loops using conditions ;) and i think this exemple may result in FPS drop.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...