From d36a31e6739bcd39c84f637344227af87cfd0ee5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 18 Jul 2019 14:58:15 -0300 Subject: Reviving HARDMEMTESTS This commit brings a new implementation for HARDMEMTESTS, which forces an emergency GC whenever possible. It also fixes some issues detected with this option: - A small bug in lvm.c: a closure could be collected by an emergency GC while being initialized. - Some tests: a memory address can be immediatly reused after a GC; for instance, two consecutive '{}' expressions can return exactly the same address, if the first one is not anchored. --- lvm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lvm.c') diff --git a/lvm.c b/lvm.c index c1b6749d..d9bd0ab3 100644 --- a/lvm.c +++ b/lvm.c @@ -1038,7 +1038,10 @@ void luaV_finishOp (lua_State *L) { ** errors. (That is, it will not return to the interpreter main loop ** after changing the stack or hooks.) */ -#define halfProtect(exp) (savepc(L), (exp)) +#define halfProtect(exp) (savestate(L,ci), (exp)) + +/* idem, but without changing the stack */ +#define halfProtectNT(exp) (savepc(L), (exp)) #define checkGC(L,c) \ @@ -1620,7 +1623,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { vmcase(OP_RETURN0) { if (L->hookmask) { L->top = ra; - halfProtect(luaD_poscall(L, ci, 0)); /* no hurry... */ + halfProtectNT(luaD_poscall(L, ci, 0)); /* no hurry... */ } else { /* do the 'poscall' here */ int nres = ci->nresults; @@ -1634,7 +1637,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { vmcase(OP_RETURN1) { if (L->hookmask) { L->top = ra + 1; - halfProtect(luaD_poscall(L, ci, 1)); /* no hurry... */ + halfProtectNT(luaD_poscall(L, ci, 1)); /* no hurry... */ } else { /* do the 'poscall' here */ int nres = ci->nresults; -- cgit v1.2.3-55-g6feb