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.
This commit is contained in:
Roberto Ierusalimschy
2019-07-18 14:58:15 -03:00
parent 024a6071ca
commit d36a31e673
4 changed files with 35 additions and 15 deletions

9
lvm.c
View File

@@ -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;