[prev in list] [next in list] [prev in thread] [next in thread]
List: lua-l
Subject: Re: checkstack questions
From: Chris Jones <cmsj () tenshu ! net>
Date: 2018-04-07 19:50:46
Message-ID: CAHWFm4dXe0nQ_9+KFgopo8g396eBxiB1PS1D2MmPKGFzVX8JLA () mail ! gmail ! com
[Download RAW message or body]
Hey
Thanks :)
Chris
On 6 April 2018 at 13:48, Roberto Ierusalimschy <roberto@inf.puc-rio.br>
wrote:
> > One other question occurred to me - what about situations where C is
> doing something in a situation where it hasn't been called from Lua? Eg a C
> callback is triggered and calls a Lua function?
> > I'm thinking in that situation it probably has no guarantee about stack
> slots and should grow the stack for everything?
>
> When Lua starts, it ensures those 20 slots. So, if each of these
> "situations" always use the stack balancedly (e.g., a callback pops
> everything it pushed), you don't need to check the stack. (If they use
> the stack unbalancedly, you are doomed to have a stack overflow sooner
> or later.)
>
> -- Roberto
>
>
--
Cheers,
Chris
[Attachment #3 (text/html)]
<div dir="ltr">Hey<div><br></div><div>Thanks \
:)</div><div><br></div><div>Chris</div></div><div class="gmail_extra"><br><div \
class="gmail_quote">On 6 April 2018 at 13:48, Roberto Ierusalimschy <span \
dir="ltr"><<a href="mailto:roberto@inf.puc-rio.br" \
target="_blank">roberto@inf.puc-rio.br</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><span class="">> One other question occurred to me - what \
about situations where C is doing something in a situation where it hasn't been \
called from Lua? Eg a C callback is triggered and calls a Lua function?<br> > I'm \
thinking in that situation it probably has no guarantee about stack slots and should \
grow the stack for everything?<br> <br>
</span>When Lua starts, it ensures those 20 slots. So, if each of these<br>
"situations" always use the stack balancedly (e.g., a callback pops<br>
everything it pushed), you don't need to check the stack. (If they use<br>
the stack unbalancedly, you are doomed to have a stack overflow sooner<br>
or later.)<br>
<span class="HOEnZb"><font color="#888888"><br>
-- Roberto<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div \
class="gmail_signature" data-smartmail="gmail_signature"><div \
dir="ltr">Cheers,<div><br></div><div>Chris</div></div></div> </div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic