diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-04-26 17:41:18 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-04-26 17:41:18 -0300 |
commit | a94ce68e0aa9cd11dece30528d8dbd0354db1798 (patch) | |
tree | 553d0088e8070467ac0b863eee39ff995b84e8b2 | |
parent | ec22fc963a9c80d81724ccdd17e967995fc988c9 (diff) | |
download | lua-a94ce68e0aa9cd11dece30528d8dbd0354db1798.tar.gz lua-a94ce68e0aa9cd11dece30528d8dbd0354db1798.tar.bz2 lua-a94ce68e0aa9cd11dece30528d8dbd0354db1798.zip |
bug: wrong handling of 'nCcalls' in coroutines
-rw-r--r-- | ldo.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.101 2011/10/07 20:45:19 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.102 2011/11/29 15:55:08 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -402,8 +402,6 @@ static void finishCcall (lua_State *L) { | |||
402 | int n; | 402 | int n; |
403 | lua_assert(ci->u.c.k != NULL); /* must have a continuation */ | 403 | lua_assert(ci->u.c.k != NULL); /* must have a continuation */ |
404 | lua_assert(L->nny == 0); | 404 | lua_assert(L->nny == 0); |
405 | /* finish 'luaD_call' */ | ||
406 | L->nCcalls--; | ||
407 | /* finish 'lua_callk' */ | 405 | /* finish 'lua_callk' */ |
408 | adjustresults(L, ci->nresults); | 406 | adjustresults(L, ci->nresults); |
409 | /* call continuation function */ | 407 | /* call continuation function */ |
@@ -484,9 +482,10 @@ static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) { | |||
484 | ** do the work for 'lua_resume' in protected mode | 482 | ** do the work for 'lua_resume' in protected mode |
485 | */ | 483 | */ |
486 | static void resume (lua_State *L, void *ud) { | 484 | static void resume (lua_State *L, void *ud) { |
485 | int nCcalls = L->nCcalls; | ||
487 | StkId firstArg = cast(StkId, ud); | 486 | StkId firstArg = cast(StkId, ud); |
488 | CallInfo *ci = L->ci; | 487 | CallInfo *ci = L->ci; |
489 | if (L->nCcalls >= LUAI_MAXCCALLS) | 488 | if (nCcalls >= LUAI_MAXCCALLS) |
490 | resume_error(L, "C stack overflow", firstArg); | 489 | resume_error(L, "C stack overflow", firstArg); |
491 | if (L->status == LUA_OK) { /* may be starting a coroutine */ | 490 | if (L->status == LUA_OK) { /* may be starting a coroutine */ |
492 | if (ci != &L->base_ci) /* not in base level? */ | 491 | if (ci != &L->base_ci) /* not in base level? */ |
@@ -513,11 +512,11 @@ static void resume (lua_State *L, void *ud) { | |||
513 | api_checknelems(L, n); | 512 | api_checknelems(L, n); |
514 | firstArg = L->top - n; /* yield results come from continuation */ | 513 | firstArg = L->top - n; /* yield results come from continuation */ |
515 | } | 514 | } |
516 | L->nCcalls--; /* finish 'luaD_call' */ | ||
517 | luaD_poscall(L, firstArg); /* finish 'luaD_precall' */ | 515 | luaD_poscall(L, firstArg); /* finish 'luaD_precall' */ |
518 | } | 516 | } |
519 | unroll(L, NULL); | 517 | unroll(L, NULL); |
520 | } | 518 | } |
519 | lua_assert(nCcalls == L->nCcalls); | ||
521 | } | 520 | } |
522 | 521 | ||
523 | 522 | ||