aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-09-29 13:41:35 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-09-29 13:41:35 -0300
commit5d4bf35ec9f240fc82cd4e94a395c652b2ab004c (patch)
tree2cdee5ef31b38d6dca37dd871fcb8d21755fcc6b
parent6063c5c61f55d15ea4abb1eed05f597deaf4a9c3 (diff)
downloadlua-5d4bf35ec9f240fc82cd4e94a395c652b2ab004c.tar.gz
lua-5d4bf35ec9f240fc82cd4e94a395c652b2ab004c.tar.bz2
lua-5d4bf35ec9f240fc82cd4e94a395c652b2ab004c.zip
bug: syntax `local function' does not increment stack size
-rw-r--r--bugs56
-rw-r--r--lparser.c11
2 files changed, 62 insertions, 5 deletions
diff --git a/bugs b/bugs
index d202ee22..7b272fbb 100644
--- a/bugs
+++ b/bugs
@@ -358,7 +358,37 @@ coroutine.resume(co)
358coroutine.resume(co) --> seg. fault 358coroutine.resume(co) --> seg. fault
359]], 359]],
360report = [[by Alex Bilyk, 09/05/2003]], 360report = [[by Alex Bilyk, 09/05/2003]],
361patch = [[???]], 361patch = [[
362* ldo.c:
363325,326c325
364< if (nargs >= L->top - L->base)
365< luaG_runerror(L, "cannot resume dead coroutine");
366---
367> lua_assert(nargs < L->top - L->base);
368329c328,329
369< else if (ci->state & CI_YIELD) { /* inside a yield? */
370---
371> else { /* inside a yield */
372> lua_assert(ci->state & CI_YIELD);
373344,345d343
374< else
375< luaG_runerror(L, "cannot resume non-suspended coroutine");
376351a350,358
377> static int resume_error (lua_State *L, const char *msg) {
378> L->top = L->ci->base;
379> setsvalue2s(L->top, luaS_new(L, msg));
380> incr_top(L);
381> lua_unlock(L);
382> return LUA_ERRRUN;
383> }
384>
385>
386355a363,366
387> if (L->ci == L->base_ci && nargs >= L->top - L->base)
388> return resume_error(L, "cannot resume dead coroutine");
389> else if (!(L->ci->state & CI_YIELD)) /* not inside a yield? */
390> return resume_error(L, "cannot resume non-suspended coroutine");
391]],
362} 392}
363 393
364 394
@@ -514,3 +544,27 @@ patch = [[
514> char buff[128]; 544> char buff[128];
515]] 545]]
516} 546}
547
548
549Bug{
550what = [[syntax `local function' does not increment stack size]],
551
552report = [[Rici Lake, 26/09/2003]],
553
554example = [[
555-- must run this with precompiled code
556local a,b,c
557local function d () end
558]],
559
560patch = [[
561* lparser.c:
5621145c1145,1146
563< init_exp(&v, VLOCAL, ls->fs->freereg++);
564---
565> init_exp(&v, VLOCAL, ls->fs->freereg);
566> luaK_reserveregs(ls->fs, 1);
567]],
568
569}
570
diff --git a/lparser.c b/lparser.c
index c551047a..a73fab43 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.217 2003/08/27 21:01:44 roberto Exp roberto $ 2** $Id: lparser.c,v 1.218 2003/09/05 14:00:27 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1167,11 +1167,13 @@ static void ifstat (LexState *ls, int line) {
1167 1167
1168static void localfunc (LexState *ls) { 1168static void localfunc (LexState *ls) {
1169 expdesc v, b; 1169 expdesc v, b;
1170 FuncState *fs = ls->fs;
1170 new_localvar(ls, str_checkname(ls), 0); 1171 new_localvar(ls, str_checkname(ls), 0);
1171 init_exp(&v, VLOCAL, ls->fs->freereg++); 1172 init_exp(&v, VLOCAL, fs->freereg);
1173 luaK_reserveregs(fs, 1);
1172 adjustlocalvars(ls, 1); 1174 adjustlocalvars(ls, 1);
1173 body(ls, &b, 0, ls->linenumber); 1175 body(ls, &b, 0, ls->linenumber);
1174 luaK_storevar(ls->fs, &v, &b); 1176 luaK_storevar(fs, &v, &b);
1175} 1177}
1176 1178
1177 1179
@@ -1346,7 +1348,8 @@ static void chunk (LexState *ls) {
1346 while (!islast && !block_follow(ls->t.token)) { 1348 while (!islast && !block_follow(ls->t.token)) {
1347 islast = statement(ls); 1349 islast = statement(ls);
1348 testnext(ls, ';'); 1350 testnext(ls, ';');
1349 lua_assert(ls->fs->freereg >= ls->fs->nactvar); 1351 lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg &&
1352 ls->fs->freereg >= ls->fs->nactvar);
1350 ls->fs->freereg = ls->fs->nactvar; /* free registers */ 1353 ls->fs->freereg = ls->fs->nactvar; /* free registers */
1351 } 1354 }
1352 leavelevel(ls); 1355 leavelevel(ls);