diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-05-25 17:41:39 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-05-25 17:41:39 -0300 |
| commit | 196bb94d66e727e0aec053a0276c3ad701500762 (patch) | |
| tree | a7639f32207179b5bd5e1ce04dd35972e1b2e148 /testes | |
| parent | 603b2c64add5fbf4b7343525cf109af0c7077695 (diff) | |
| download | lua-196bb94d66e727e0aec053a0276c3ad701500762.tar.gz lua-196bb94d66e727e0aec053a0276c3ad701500762.tar.bz2 lua-196bb94d66e727e0aec053a0276c3ad701500762.zip | |
Bug: 'lua_settop' may use an invalid pointer to stack
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/locals.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/testes/locals.lua b/testes/locals.lua index 62a88df5..ddb75054 100644 --- a/testes/locals.lua +++ b/testes/locals.lua | |||
| @@ -592,6 +592,28 @@ end | |||
| 592 | 592 | ||
| 593 | if rawget(_G, "T") then | 593 | if rawget(_G, "T") then |
| 594 | 594 | ||
| 595 | do | ||
| 596 | -- bug in 5.4.3 | ||
| 597 | -- 'lua_settop' may use a pointer to stack invalidated by 'luaF_close' | ||
| 598 | |||
| 599 | -- reduce stack size | ||
| 600 | collectgarbage(); collectgarbage(); collectgarbage() | ||
| 601 | |||
| 602 | -- force a stack reallocation | ||
| 603 | local function loop (n) | ||
| 604 | if n < 400 then loop(n + 1) end | ||
| 605 | end | ||
| 606 | |||
| 607 | -- close metamethod will reallocate the stack | ||
| 608 | local o = setmetatable({}, {__close = function () loop(0) end}) | ||
| 609 | |||
| 610 | local script = [[toclose 2; settop 1; return 1]] | ||
| 611 | |||
| 612 | assert(T.testC(script, o) == script) | ||
| 613 | |||
| 614 | end | ||
| 615 | |||
| 616 | |||
| 595 | -- memory error inside closing function | 617 | -- memory error inside closing function |
| 596 | local function foo () | 618 | local function foo () |
| 597 | local y <close> = func2close(function () T.alloccount() end) | 619 | local y <close> = func2close(function () T.alloccount() end) |
