From eb41999461b6f428186c55abd95f4ce1a76217d5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 7 Jul 2020 18:03:48 -0300 Subject: Fixed bugs of stack reallocation x GC Macro 'checkstackGC' was doing a GC step after resizing the stack; the GC could shrink the stack and undo the resize. Moreover, macro 'checkstackp' also does a GC step, which could remove the preallocated CallInfo when calling a function. (Its name has been changed to 'checkstackGCp' to emphasize that it calls the GC.) --- ldo.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ldo.h') diff --git a/ldo.h b/ldo.h index 7760f853..6c6cb285 100644 --- a/ldo.h +++ b/ldo.h @@ -17,6 +17,8 @@ ** Macro to check stack size and grow stack if needed. Parameters ** 'pre'/'pos' allow the macro to preserve a pointer into the ** stack across reallocations, doing the work only when needed. +** It also allows the running of one GC step when the stack is +** reallocated. ** 'condmovestack' is used in heavy tests to force a stack reallocation ** at every check. */ @@ -35,7 +37,7 @@ /* macro to check stack size, preserving 'p' */ -#define checkstackp(L,n,p) \ +#define checkstackGCp(L,n,p) \ luaD_checkstackaux(L, n, \ ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ luaC_checkGC(L), /* stack grow uses memory */ \ @@ -44,7 +46,7 @@ /* macro to check stack size and GC */ #define checkstackGC(L,fsize) \ - luaD_checkstackaux(L, (fsize), (void)0, luaC_checkGC(L)) + luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) /* type of protected functions, to be ran by 'runprotected' */ -- cgit v1.2.3-55-g6feb