lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


云风 Cloud Wu <cloudwu@gmail.com> 于2020年11月4日周三 上午10:10写道:
>
> This patch can fix it :
>
> --- a/ldo.c
> +++ b/ldo.c
> @@ -191,7 +191,7 @@ int luaD_reallocstack (lua_State *L, int newsize,
> int raiseerror) {
>        luaM_error(L);
>      else return 0;  /* do not raise an error */
>    }
> -  for (; lim < newsize; lim++)
> +  for (; lim < newsize + EXTRA_STACK; lim++)
>      setnilvalue(s2v(newstack + lim)); /* erase new segment */
>    correctstack(L, L->stack, newstack);
>    L->stack = newstack;
> diff --git a/lstate.h b/lstate.h
> index cbcf07e2..5f651108 100644
> --- a/lstate.h
> +++ b/lstate.h
> @@ -139,7 +139,7 @@ struct lua_longjmp;  /* defined in ldo.c */
>
>  #define BASIC_STACK_SIZE        (2*LUA_MINSTACK)
>
> -#define stacksize(th)  cast_int((th)->stack_last - (th)->stack)
> +#define stacksize(th)  cast_int((th)->stack_last + EXTRA_STACK - (th)->stack)
>

Sorry , I should not change the macro stacksize. The patch should be :

--- a/src/ldo.c
+++ b/src/ldo.c
@@ -192,7 +192,7 @@ int luaD_reallocstack (lua_State *L, int newsize,
int raiseerror) {
     else return 0;  /* do not raise an error */
   }
   for (; lim < newsize; lim++)
-    setnilvalue(s2v(newstack + lim)); /* erase new segment */
+    setnilvalue(s2v(newstack + lim + EXTRA_STACK)); /* erase new segment */
   correctstack(L, L->stack, newstack);
   L->stack = newstack;
   L->stack_last = L->stack + newsize;


-- 
http://blog.codingnow.com