diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-07 18:03:48 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-07 18:03:48 -0300 |
| commit | eb41999461b6f428186c55abd95f4ce1a76217d5 (patch) | |
| tree | 577e56c4ad5999b34966232b1e2a2bf9a63f7cc2 /ldo.h | |
| parent | 314c6057b785cd94ac88905ccfce61724107d66b (diff) | |
| download | lua-eb41999461b6f428186c55abd95f4ce1a76217d5.tar.gz lua-eb41999461b6f428186c55abd95f4ce1a76217d5.tar.bz2 lua-eb41999461b6f428186c55abd95f4ce1a76217d5.zip | |
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.)
Diffstat (limited to 'ldo.h')
| -rw-r--r-- | ldo.h | 6 |
1 files changed, 4 insertions, 2 deletions
| @@ -17,6 +17,8 @@ | |||
| 17 | ** Macro to check stack size and grow stack if needed. Parameters | 17 | ** Macro to check stack size and grow stack if needed. Parameters |
| 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the | 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the |
| 19 | ** stack across reallocations, doing the work only when needed. | 19 | ** stack across reallocations, doing the work only when needed. |
| 20 | ** It also allows the running of one GC step when the stack is | ||
| 21 | ** reallocated. | ||
| 20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation | 22 | ** 'condmovestack' is used in heavy tests to force a stack reallocation |
| 21 | ** at every check. | 23 | ** at every check. |
| 22 | */ | 24 | */ |
| @@ -35,7 +37,7 @@ | |||
| 35 | 37 | ||
| 36 | 38 | ||
| 37 | /* macro to check stack size, preserving 'p' */ | 39 | /* macro to check stack size, preserving 'p' */ |
| 38 | #define checkstackp(L,n,p) \ | 40 | #define checkstackGCp(L,n,p) \ |
| 39 | luaD_checkstackaux(L, n, \ | 41 | luaD_checkstackaux(L, n, \ |
| 40 | ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ | 42 | ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ |
| 41 | luaC_checkGC(L), /* stack grow uses memory */ \ | 43 | luaC_checkGC(L), /* stack grow uses memory */ \ |
| @@ -44,7 +46,7 @@ | |||
| 44 | 46 | ||
| 45 | /* macro to check stack size and GC */ | 47 | /* macro to check stack size and GC */ |
| 46 | #define checkstackGC(L,fsize) \ | 48 | #define checkstackGC(L,fsize) \ |
| 47 | luaD_checkstackaux(L, (fsize), (void)0, luaC_checkGC(L)) | 49 | luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) |
| 48 | 50 | ||
| 49 | 51 | ||
| 50 | /* type of protected functions, to be ran by 'runprotected' */ | 52 | /* type of protected functions, to be ran by 'runprotected' */ |
