* [Tarantool-patches] [PATCH luajit] test: adapt test checking reversed function @ 2021-09-30 11:43 Maxim Kokryashkin via Tarantool-patches 2021-10-11 15:28 ` Sergey Kaplun via Tarantool-patches 0 siblings, 1 reply; 5+ messages in thread From: Maxim Kokryashkin via Tarantool-patches @ 2021-09-30 11:43 UTC (permalink / raw) To: tarantool-patches, imun, skaplun, m.shishatskiy The first fiber in Tarantool has only 512Kb of the stack which is not enough to handle such a deep call chain. The test is adapted to Tarantool by decreasing the string length. Closes tarantool/tarantool#5782 Part of tarantool/tarantool#5845 Part of tarantool/tarantool#4473 --- GitHub branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5782-adapt-deep-nest-gsub-PUC-Rio Issue: https://github.com/tarantool/tarantool/issues/5782 test/PUC-Rio-Lua-5.1-tests/pm.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/PUC-Rio-Lua-5.1-tests/pm.lua b/test/PUC-Rio-Lua-5.1-tests/pm.lua index e364ff9d..7da3ef4a 100644 --- a/test/PUC-Rio-Lua-5.1-tests/pm.lua +++ b/test/PUC-Rio-Lua-5.1-tests/pm.lua @@ -206,12 +206,11 @@ function rev (s) return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) end -local x = string.rep('012345', 10) --- FIXME: The first Tarantool's fiber has only 512Kb of stack. --- It is not enough for this recursive call. +-- This test is adapted to match the stack size (512Kb) of the first fiber in +-- Tarantool. -- See also https://github.com/tarantool/tarantool/issues/5782. --- The test is disabled for Tarantool binary. --- assert(rev(rev(x)) == x) +local x = string.rep('01234', 10) +assert(rev(rev(x)) == x) -- gsub with tables -- 2.33.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit] test: adapt test checking reversed function 2021-09-30 11:43 [Tarantool-patches] [PATCH luajit] test: adapt test checking reversed function Maxim Kokryashkin via Tarantool-patches @ 2021-10-11 15:28 ` Sergey Kaplun via Tarantool-patches 2021-10-11 20:19 ` Максим Корякшин via Tarantool-patches 0 siblings, 1 reply; 5+ messages in thread From: Sergey Kaplun via Tarantool-patches @ 2021-10-11 15:28 UTC (permalink / raw) To: Maxim Kokryashkin; +Cc: tarantool-patches Hi, Maxim! Thanks for the patch! Please consider my comments below. On 30.09.21, Maxim Kokryashkin wrote: > The first fiber in Tarantool has only 512Kb of the stack which is not enough to > handle such a deep call chain. > The test is adapted to Tarantool by decreasing the string length. > > Closes tarantool/tarantool#5782 > Part of tarantool/tarantool#5845 > Part of tarantool/tarantool#4473 Looks like it should be 5870 instead 4473. Also, 5845 is already closed. > --- Please show the Tarantool branch as well, to show that problem is gone. > GitHub branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5782-adapt-deep-nest-gsub-PUC-Rio > Issue: https://github.com/tarantool/tarantool/issues/5782 > > test/PUC-Rio-Lua-5.1-tests/pm.lua | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/test/PUC-Rio-Lua-5.1-tests/pm.lua b/test/PUC-Rio-Lua-5.1-tests/pm.lua > index e364ff9d..7da3ef4a 100644 > --- a/test/PUC-Rio-Lua-5.1-tests/pm.lua > +++ b/test/PUC-Rio-Lua-5.1-tests/pm.lua > @@ -206,12 +206,11 @@ function rev (s) > return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) > end > > -local x = string.rep('012345', 10) > --- FIXME: The first Tarantool's fiber has only 512Kb of stack. > --- It is not enough for this recursive call. > +-- This test is adapted to match the stack size (512Kb) of the first fiber in > +-- Tarantool. > -- See also https://github.com/tarantool/tarantool/issues/5782. > --- The test is disabled for Tarantool binary. > --- assert(rev(rev(x)) == x) > +local x = string.rep('01234', 10) > +assert(rev(rev(x)) == x) The patch is looks OK to me, but the main problem is still here: LuaJIT is badly managing C stack overflow. The same chunk rases an error for Lua 5.1, but crashes for LuaJIT. | $ luajit -e 'local function rev (s) return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) end local x = string.rep("0", 1000) rev(x)' | Segmentation fault | $ lua -e 'local function rev (s) return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) end local x = string.rep("0", 1000) rev(x)' | lua: C stack overflow | stack traceback: | [C]: in function 'gsub' | (command line):1: in function 'rev' | (command line):1: in function <(command line):1> | [C]: in function 'gsub' | (command line):1: in function 'rev' | (command line):1: in function <(command line):1> | [C]: in function 'gsub' | (command line):1: in function 'rev' | (command line):1: in function <(command line):1> | [C]: in function 'gsub' | ... | [C]: in function 'gsub' | (command line):1: in function 'rev' | (command line):1: in function <(command line):1> | [C]: in function 'gsub' | (command line):1: in function 'rev' | (command line):1: in function <(command line):1> | [C]: in function 'gsub' | (command line):1: in function 'rev' | (command line):1: in main chunk | [C]: ? So I suppose it is strange to add test that tests nothing. Thoughts? > > > -- gsub with tables > -- > 2.33.0 > -- Best regards, Sergey Kaplun ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit] test: adapt test checking reversed function 2021-10-11 15:28 ` Sergey Kaplun via Tarantool-patches @ 2021-10-11 20:19 ` Максим Корякшин via Tarantool-patches 2021-10-12 8:16 ` Sergey Kaplun via Tarantool-patches 2022-02-18 19:04 ` Igor Munkin via Tarantool-patches 0 siblings, 2 replies; 5+ messages in thread From: Максим Корякшин via Tarantool-patches @ 2021-10-11 20:19 UTC (permalink / raw) To: Sergey Kaplun; +Cc: Maxim Kokryashkin, tarantool-patches [-- Attachment #1: Type: text/plain, Size: 3395 bytes --] Hi! Thanks for the comments. I agree that it is strange to add this test, as long as it does not test anything, so I propose to remove it. Best regards, Maxim Kokryashkin > >>Hi, Maxim! >> >>Thanks for the patch! >> >>Please consider my comments below. >> >>On 30.09.21, Maxim Kokryashkin wrote: >>> The first fiber in Tarantool has only 512Kb of the stack which is not enough to >>> handle such a deep call chain. >>> The test is adapted to Tarantool by decreasing the string length. >>> >>> Closes tarantool/tarantool#5782 >>> Part of tarantool/tarantool#5845 >>> Part of tarantool/tarantool#4473 >> >>Looks like it should be 5870 instead 4473. Also, 5845 is already >>closed. >> >>> --- >> >>Please show the Tarantool branch as well, to show that problem is gone. >> >>> GitHub branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5782-adapt-deep-nest-gsub-PUC-Rio >>> Issue: https://github.com/tarantool/tarantool/issues/5782 >>> >>> test/PUC-Rio-Lua-5.1-tests/pm.lua | 9 ++++----- >>> 1 file changed, 4 insertions(+), 5 deletions(-) >>> >>> diff --git a/test/PUC-Rio-Lua-5.1-tests/pm.lua b/test/PUC-Rio-Lua-5.1-tests/pm.lua >>> index e364ff9d..7da3ef4a 100644 >>> --- a/test/PUC-Rio-Lua-5.1-tests/pm.lua >>> +++ b/test/PUC-Rio-Lua-5.1-tests/pm.lua >>> @@ -206,12 +206,11 @@ function rev (s) >>> return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) >>> end >>> >>> -local x = string.rep('012345', 10) >>> --- FIXME: The first Tarantool's fiber has only 512Kb of stack. >>> --- It is not enough for this recursive call. >>> +-- This test is adapted to match the stack size (512Kb) of the first fiber in >>> +-- Tarantool. >>> -- See also https://github.com/tarantool/tarantool/issues/5782 . >>> --- The test is disabled for Tarantool binary. >>> --- assert(rev(rev(x)) == x) >>> +local x = string.rep('01234', 10) >>> +assert(rev(rev(x)) == x) >> >>The patch is looks OK to me, but the main problem is still here: >>LuaJIT is badly managing C stack overflow. The same chunk rases an error >>for Lua 5.1, but crashes for LuaJIT. >> >>| $ luajit -e 'local function rev (s) return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) end local x = string.rep("0", 1000) rev(x)' >>| Segmentation fault >> >>| $ lua -e 'local function rev (s) return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) end local x = string.rep("0", 1000) rev(x)' >>| lua: C stack overflow >>| stack traceback: >>| [C]: in function 'gsub' >>| (command line):1: in function 'rev' >>| (command line):1: in function <(command line):1> >>| [C]: in function 'gsub' >>| (command line):1: in function 'rev' >>| (command line):1: in function <(command line):1> >>| [C]: in function 'gsub' >>| (command line):1: in function 'rev' >>| (command line):1: in function <(command line):1> >>| [C]: in function 'gsub' >>| ... >>| [C]: in function 'gsub' >>| (command line):1: in function 'rev' >>| (command line):1: in function <(command line):1> >>| [C]: in function 'gsub' >>| (command line):1: in function 'rev' >>| (command line):1: in function <(command line):1> >>| [C]: in function 'gsub' >>| (command line):1: in function 'rev' >>| (command line):1: in main chunk >>| [C]: ? >> >>So I suppose it is strange to add test that tests nothing. >> >>Thoughts? >> >>> >>> >>> -- gsub with tables >>> -- >>> 2.33.0 >>> >> >>-- >>Best regards, >>Sergey Kaplun > [-- Attachment #2: Type: text/html, Size: 4370 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit] test: adapt test checking reversed function 2021-10-11 20:19 ` Максим Корякшин via Tarantool-patches @ 2021-10-12 8:16 ` Sergey Kaplun via Tarantool-patches 2022-02-18 19:04 ` Igor Munkin via Tarantool-patches 1 sibling, 0 replies; 5+ messages in thread From: Sergey Kaplun via Tarantool-patches @ 2021-10-12 8:16 UTC (permalink / raw) To: Максим Корякшин Cc: Maxim Kokryashkin, tarantool-patches Hi! Thanks for the answer! On 11.10.21, Максим Корякшин wrote: > > Hi! Thanks for the comments. > > I agree that it is strange to add this test, as long as it does not test > anything, so I propose to remove it. May be as an option, but IMO it is better to leave it commented instead, as a reminder about the problem. Lets wait for the second reviewer here. I'm OK with both solutions. > > Best regards, > Maxim Kokryashkin > > > > >>Hi, Maxim! > >> > >>Thanks for the patch! > >> > >>Please consider my comments below. > >> > >>On 30.09.21, Maxim Kokryashkin wrote: > >>> The first fiber in Tarantool has only 512Kb of the stack which is not enough to > >>> handle such a deep call chain. > >>> The test is adapted to Tarantool by decreasing the string length. > >>> > >>> Closes tarantool/tarantool#5782 > >>> Part of tarantool/tarantool#5845 > >>> Part of tarantool/tarantool#4473 > >> > >>Looks like it should be 5870 instead 4473. Also, 5845 is already > >>closed. > >> > >>> --- > >> > >>Please show the Tarantool branch as well, to show that problem is gone. > >> > >>> GitHub branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5782-adapt-deep-nest-gsub-PUC-Rio > >>> Issue: https://github.com/tarantool/tarantool/issues/5782 > >>> > >>> test/PUC-Rio-Lua-5.1-tests/pm.lua | 9 ++++----- > >>> 1 file changed, 4 insertions(+), 5 deletions(-) > >>> > >>> diff --git a/test/PUC-Rio-Lua-5.1-tests/pm.lua b/test/PUC-Rio-Lua-5.1-tests/pm.lua > >>> index e364ff9d..7da3ef4a 100644 > >>> --- a/test/PUC-Rio-Lua-5.1-tests/pm.lua > >>> +++ b/test/PUC-Rio-Lua-5.1-tests/pm.lua > >>> @@ -206,12 +206,11 @@ function rev (s) > >>> return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) > >>> end > >>> > >>> -local x = string.rep('012345', 10) > >>> --- FIXME: The first Tarantool's fiber has only 512Kb of stack. > >>> --- It is not enough for this recursive call. > >>> +-- This test is adapted to match the stack size (512Kb) of the first fiber in > >>> +-- Tarantool. > >>> -- See also https://github.com/tarantool/tarantool/issues/5782 . > >>> --- The test is disabled for Tarantool binary. > >>> --- assert(rev(rev(x)) == x) > >>> +local x = string.rep('01234', 10) > >>> +assert(rev(rev(x)) == x) > >> > >>The patch is looks OK to me, but the main problem is still here: > >>LuaJIT is badly managing C stack overflow. The same chunk rases an error > >>for Lua 5.1, but crashes for LuaJIT. > >> > >>| $ luajit -e 'local function rev (s) return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) end local x = string.rep("0", 1000) rev(x)' > >>| Segmentation fault > >> > >>| $ lua -e 'local function rev (s) return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end) end local x = string.rep("0", 1000) rev(x)' > >>| lua: C stack overflow > >>| stack traceback: > >>| [C]: in function 'gsub' > >>| (command line):1: in function 'rev' > >>| (command line):1: in function <(command line):1> > >>| [C]: in function 'gsub' > >>| (command line):1: in function 'rev' > >>| (command line):1: in function <(command line):1> > >>| [C]: in function 'gsub' > >>| (command line):1: in function 'rev' > >>| (command line):1: in function <(command line):1> > >>| [C]: in function 'gsub' > >>| ... > >>| [C]: in function 'gsub' > >>| (command line):1: in function 'rev' > >>| (command line):1: in function <(command line):1> > >>| [C]: in function 'gsub' > >>| (command line):1: in function 'rev' > >>| (command line):1: in function <(command line):1> > >>| [C]: in function 'gsub' > >>| (command line):1: in function 'rev' > >>| (command line):1: in main chunk > >>| [C]: ? > >> > >>So I suppose it is strange to add test that tests nothing. > >> > >>Thoughts? > >> > >>> > >>> > >>> -- gsub with tables > >>> -- > >>> 2.33.0 > >>> > >> > >>-- > >>Best regards, > >>Sergey Kaplun > > -- Best regards, Sergey Kaplun ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit] test: adapt test checking reversed function 2021-10-11 20:19 ` Максим Корякшин via Tarantool-patches 2021-10-12 8:16 ` Sergey Kaplun via Tarantool-patches @ 2022-02-18 19:04 ` Igor Munkin via Tarantool-patches 1 sibling, 0 replies; 5+ messages in thread From: Igor Munkin via Tarantool-patches @ 2022-02-18 19:04 UTC (permalink / raw) To: Максим Корякшин Cc: tarantool-patches, Maxim Kokryashkin Max, Thanks for the patch! On 11.10.21, Максим Корякшин wrote: > > Hi! Thanks for the comments. > > I agree that it is strange to add this test, as long as it does not test > anything, so I propose to remove it. Why do you think this test checks nothing? It checks <string.gsub> with recursive handler. If author wanted to check deep recursion exception, he would add <pcall> at least (if Lua successfully handles this). I propose to apply the original fix[1], but adjust the comment considering Sergey review: it provides the description, why we can't use the original test, or at least add <pcall> to avoid the crash. > > Best regards, > Maxim Kokryashkin > > > > >>Hi, Maxim! > >> > >>Thanks for the patch! > >> > >>Please consider my comments below. > >> > >>On 30.09.21, Maxim Kokryashkin wrote: > >>> The first fiber in Tarantool has only 512Kb of the stack which is not enough to > >>> handle such a deep call chain. > >>> The test is adapted to Tarantool by decreasing the string length. > >>> > >>> Closes tarantool/tarantool#5782 Typo: s/Closes/Resolves/. > >>> Part of tarantool/tarantool#5845 > >>> Part of tarantool/tarantool#4473 Minor: Replace both tags above with "Part of tarantool/tarantool/5870". > >> > >>Looks like it should be 5870 instead 4473. Also, 5845 is already > >>closed. > >> > >>> --- > >> > >>Please show the Tarantool branch as well, to show that problem is gone. > >> > >>> GitHub branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5782-adapt-deep-nest-gsub-PUC-Rio > >>> Issue: https://github.com/tarantool/tarantool/issues/5782 > >>> > >>> test/PUC-Rio-Lua-5.1-tests/pm.lua | 9 ++++----- > >>> 1 file changed, 4 insertions(+), 5 deletions(-) > >>> <snipped> > >>> -- > >>> 2.33.0 > >>> > >> > >>-- > >>Best regards, > >>Sergey Kaplun > > [1]: https://lists.tarantool.org/tarantool-patches/20210930114337.1575120-1-m.kokryashkin@tarantool.org/ -- Best regards, IM ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-18 19:08 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-09-30 11:43 [Tarantool-patches] [PATCH luajit] test: adapt test checking reversed function Maxim Kokryashkin via Tarantool-patches 2021-10-11 15:28 ` Sergey Kaplun via Tarantool-patches 2021-10-11 20:19 ` Максим Корякшин via Tarantool-patches 2021-10-12 8:16 ` Sergey Kaplun via Tarantool-patches 2022-02-18 19:04 ` Igor Munkin via Tarantool-patches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox