diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-28 16:45:15 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-28 16:45:15 -0300 |
commit | 69dd9461e5aeb98fe9bbc71f1e81859d03ec8a34 (patch) | |
tree | d9505d7a0e89940c55ff0a1fd3c13311b9084197 /lstate.c | |
parent | 6b6bc532a4f5e335540e6f19914cfe8435d064ed (diff) | |
download | lua-69dd9461e5aeb98fe9bbc71f1e81859d03ec8a34.tar.gz lua-69dd9461e5aeb98fe9bbc71f1e81859d03ec8a34.tar.bz2 lua-69dd9461e5aeb98fe9bbc71f1e81859d03ec8a34.zip |
bug: GC metamethod calls could mess C/Lua stack syncronization
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 1.119 2003/02/10 17:32:50 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.120 2003/02/13 16:07:57 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -206,9 +206,14 @@ static void callallgcTM (lua_State *L, void *ud) { | |||
206 | LUA_API void lua_close (lua_State *L) { | 206 | LUA_API void lua_close (lua_State *L) { |
207 | lua_lock(L); | 207 | lua_lock(L); |
208 | L = G(L)->mainthread; /* only the main thread can be closed */ | 208 | L = G(L)->mainthread; /* only the main thread can be closed */ |
209 | luaF_close(L, L->stack); /* close all upvalues for this thread */ | ||
209 | luaC_separateudata(L); /* separate udata that have GC metamethods */ | 210 | luaC_separateudata(L); /* separate udata that have GC metamethods */ |
210 | /* repeat until no more errors */ | 211 | L->errfunc = 0; /* no error function during GC metamethods */ |
211 | while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0) /* skip */; | 212 | do { /* repeat until no more errors */ |
213 | L->ci = L->base_ci; | ||
214 | L->base = L->top = L->ci->base; | ||
215 | L->nCcalls = 0; | ||
216 | } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); | ||
212 | lua_assert(G(L)->tmudata == NULL); | 217 | lua_assert(G(L)->tmudata == NULL); |
213 | close_state(L); | 218 | close_state(L); |
214 | } | 219 | } |