lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> -----Original Message-----
> From: Roger Leigh
> Sent: Saturday, March 18, 2023 9:30 PM
> To: Lua mailing list <lua-l@lists.lua.org>
> Subject: CMake support for Lua
> 
> Hi folks,
> 
> I saw that there were some existing projects which have worked on adding
> CMake support for Lua.  The main one seems to be
> https://github.com/LuaDist/lua, but this seems to no longer be active for
> some time.
> 
> https://github.com/lubgr/lua-cmake is a more recent take, but it's very simple
> and it's tracking https://github.com/lua/lua as a submodule which is missing
> luac.c -- I never saw any reply to my question asking why this is missing from
> the GitHub mirror.
> https://github.com/bencsikandrei/lua-cmake is again more recent and has
> some nice features, but it's not maintained and is missing some details
> 
> As a result, I've started this project recently:
> https://gitlab.com/codelibre/lua/lua-cmake

I've started working on making it automatically run the Lua test suite with CTest.  It's working on FreeBSD and Linux for several configurations (the exception being C++ with loadable modules for the moment).  I made some small adaptions to pass the build configuration into the test environment so it could adapt to readline being used or loadable module support being disabled.

I also made some changes to files.lua to accommodate encoding string length differences in a UTF-8 locale:

-assert(io.read(5, 'l') == '"<E1>lo"')
+assert(io.read(string.len('"�lo"'), 'l') == '"�lo"')

-assert(io.read(1) == "<E7>")
+assert(io.read(string.len("�")) == "�")

I think the encoding has been a bit mangled here--it's not clear what the original encoding was.  The change to use string.len makes it adapt to the Unicode replacement.  That might not be necessary if the file was UTF-8-encoded in the first place.  Could I suggest that this be recoded as UTF-8, and likewise for any other source files which are not plain ASCII.

     {"kill -s HUP $$", "signal", 1},
     {"kill -s KILL $$", "signal", 9},
-    {"sh -c 'kill -s HUP $$'", "exit"},
+    -- FreeBSD and Linux are reporting signal, not exit for "sh -c 'kill -s HUP $$'"
+    {"sh -c 'kill -s HUP $$'", "signal"},
     {progname .. ' -e " "', "ok"},

This test fails for me on FreeBSD and Linux.  It's expecting "exit", but I always get "signal" as for the other uses of kill, above.  Which platforms does the current "exit" test case pass on?


I've then tried to start running the tests on Windows, but I'm encountering an error:

1: ***** FILE 'cstack.lua'*****
1: testing stack overflow detection
1: testing stack overflow in message handling
1: .final count: 	250036
1: testing recursion inside pattern matching
1: testing stack-overflow in recursive 'gsub'
Exception: SegFault

It looks like it's actually overflowing the C stack.  The Lua stack is only ~31KiB in size.  Should Lua be coping with this on Windows, as it appears to be doing on Unix, or is this a defect?



Kind regards,
Roger


The details of the failure:

Exception = Exception 0xc00000fd encountered at address 0x7ff7abd0fe1c: Stack overflow
L = {lua_State *} 0x0000026349afd298 {next=0x0000000000000000 {next=???, tt=<error>, marked=<error>}, tt=8 '\b', marked=8 '\b', ...}
 next = {GCObject *} NULL
 tt = {unsigned char} 8 '\b'
 marked = {unsigned char} 8 '\b'
 status = {unsigned char} 0 '\0'
 allowhook = {unsigned char} 1 '\x1'
 nci = {unsigned short} 62514
 top = {StackValue *} 0x0000026351884280 {val={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, f=0xcdcdcdcdcdcdcdcd, ...}, tt_=0 '\0'}, tbclist={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, ...}, ...}}
 l_G = {global_State *} 0x0000026349afd360 {frealloc=0x00007ff7abce12d0 {lua.exe!l_alloc(void *,void *,unsigned long long,unsigned long long)}, ud=0x0000000000000000, totalbytes=42196600, ...}
 ci = {CallInfo *} 0x000002635193df20 {func=0x0000026351884240 {val={value_={gc=0x00007ff7abd0fe00 {lua.exe!str_gsub(lua_State *)} {next=0x81485708244c8948 {next=???, tt=<error>, marked=<error>}, tt=236 'ì', marked=96 '`'}, p=0x00007ff7abd0fe00 {lua.exe!str_gsub(lua_State *)}, ...}, ...}, ...}, ...}
 stack_last = {StackValue *} 0x0000026351887c50 {val={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, f=0xcdcdcdcdcdcdcdcd, ...}, tt_=0 '\0'}, tbclist={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, ...}, ...}}
 stack = {StackValue *} 0x0000026351880050 {val={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, f=0xcdcdcdcdcdcdcdcd, ...}, tt_=0 '\0'}, tbclist={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, f=0xcdcdcdcdcdcdcdcd, ...}, tt_=0 '\0', delta=52685}}
 openupval = {UpVal *} 0x000002634f71d080 {next=0x000002634f71d7f0 {next=0x000002634ea8f110 {next=0x000002634b8be220 {next=0x000002634f71dbe0 {next=0x000002634ba81990 {next=0x000002634b873040 {next=0x000002634cda00b0 {next=0x000002634ba845c0 {next=0x000002634b6e6710 {next=0x000002634ba840f0 {...}, ...}, ...}, ...}, ...}, ...}, ...}, ...}, ...}, ...}, ...}
 tbclist = {StackValue *} 0x0000026351880050 {val={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, f=0xcdcdcdcdcdcdcdcd, ...}, tt_=0 '\0'}, tbclist={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, ...}, ...}}
 gclist = {GCObject *} NULL
 twups = {lua_State *} NULL
 errorJmp = {lua_longjmp *} 0x000000f29bcfde40 {previous=0x000000f29bcff0e0 {previous=0x000000f29bcff5c0 {previous=0x0000000000000000 {previous=???, b=0xffffffffffffffff {{Part=0xffffffffffffffff {???, ???}}, {Part=0xffffffffffffffff {???, ???}}, {Part=0xffffffffffffffff {???, ???}}, ...}, ...}, ...}, ...}, ...}
 base_ci = {CallInfo} {func=0x0000026351880050 {val={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, f=0xcdcdcdcdcdcdcdcd, ...}, tt_=0 '\0'}, tbclist={value_={gc=0xcdcdcdcdcdcdcdcd {next=???, tt=<error>, marked=<error>}, p=0xcdcdcdcdcdcdcdcd, ...}, ...}}, ...}
 hook = {void (*volatile)(lua_State *, lua_Debug *)} NULL
 errfunc = {long long} 0
 nCcalls = {unsigned int} 11272363
 oldpc = {int} 1144
 basehookcount = {int} 0
 hookcount = {int} 0
 hookmask = {volatile int} 0
func = {StackValue *} 0x0000026351884240 {val={value_={gc=0x00007ff7abd0fe00 {lua.exe!str_gsub(lua_State *)} {next=0x81485708244c8948 {next=???, tt=<error>, marked=<error>}, tt=236 'ì', marked=96 '`'}, p=0x00007ff7abd0fe00 {lua.exe!str_gsub(lua_State *)}, f=0x00007ff7abd0fe00 {lua.exe!str_gsub(lua_State *)}, ...}, ...}, ...}
nresults = {int} 0
f = {int (*)(lua_State *)} 0x00007ff7abd0fe00 {lua.exe!str_gsub(lua_State *)}
n = {int} 0
ci = {CallInfo *} 0x000002635193df20 {func=0x0000026351884240 {val={value_={gc=0x00007ff7abd0fe00 {lua.exe!str_gsub(lua_State *)} {next=0x81485708244c8948 {next=???, tt=<error>, marked=<error>}, tt=236 'ì', marked=96 '`'}, p=0x00007ff7abd0fe00 {lua.exe!str_gsub(lua_State *)}, ...}, ...}, ...}, ...}

str_gsub(lua_State *) lstrlib.c:942
precallC(lua_State *, StackValue *, int, int (*)(lua_State *)) ldo.c:506
luaD_precall(lua_State *, StackValue *, int) ldo.c:572
luaV_execute(lua_State *, CallInfo *) lvm.c:1636
ccall(lua_State *, StackValue *, int, int) ldo.c:609
luaD_callnoyield(lua_State *, StackValue *, int) ldo.c:627
lua_callk(lua_State *, int, int, long long, int (*)(lua_State *, int, long long)) lapi.c:1023
add_value(MatchState *, luaL_Buffer *, const char *, const char *, int) lstrlib.c:914
[... lots of repetition elided ...]
str_gsub(lua_State *) lstrlib.c:967
precallC(lua_State *, StackValue *, int, int (*)(lua_State *)) ldo.c:506
luaD_precall(lua_State *, StackValue *, int) ldo.c:572
luaV_execute(lua_State *, CallInfo *) lvm.c:1636
ccall(lua_State *, StackValue *, int, int) ldo.c:609
luaD_callnoyield(lua_State *, StackValue *, int) ldo.c:627
lua_callk(lua_State *, int, int, long long, int (*)(lua_State *, int, long long)) lapi.c:1023
add_value(MatchState *, luaL_Buffer *, const char *, const char *, int) lstrlib.c:914
str_gsub(lua_State *) lstrlib.c:967
precallC(lua_State *, StackValue *, int, int (*)(lua_State *)) ldo.c:506
luaD_precall(lua_State *, StackValue *, int) ldo.c:572
luaV_execute(lua_State *, CallInfo *) lvm.c:1636
ccall(lua_State *, StackValue *, int, int) ldo.c:609
luaD_callnoyield(lua_State *, StackValue *, int) ldo.c:627
f_call(lua_State *, void *) lapi.c:1041
luaD_rawrunprotected(lua_State *, void (*)(lua_State *, void *), void *) ldo.c:144
luaD_pcall(lua_State *, void (*)(lua_State *, void *), void *, long long, long long) ldo.c:926
lua_pcallk(lua_State *, int, int, int, long long, int (*)(lua_State *, int, long long)) lapi.c:1067
luaB_pcall(lua_State *) lbaselib.c:477
precallC(lua_State *, StackValue *, int, int (*)(lua_State *)) ldo.c:506
luaD_precall(lua_State *, StackValue *, int) ldo.c:572
luaV_execute(lua_State *, CallInfo *) lvm.c:1636
ccall(lua_State *, StackValue *, int, int) ldo.c:609
luaD_callnoyield(lua_State *, StackValue *, int) ldo.c:627
f_call(lua_State *, void *) lapi.c:1041
luaD_rawrunprotected(lua_State *, void (*)(lua_State *, void *), void *) ldo.c:144
luaD_pcall(lua_State *, void (*)(lua_State *, void *), void *, long long, long long) ldo.c:926
lua_pcallk(lua_State *, int, int, int, long long, int (*)(lua_State *, int, long long)) lapi.c:1067
docall(lua_State *, int, int) lua.c:160
handle_script(lua_State *, char **) lua.c:255
pmain(lua_State *) lua.c:633
precallC(lua_State *, StackValue *, int, int (*)(lua_State *)) ldo.c:506
luaD_precall(lua_State *, StackValue *, int) ldo.c:572
ccall(lua_State *, StackValue *, int, int) ldo.c:607
luaD_callnoyield(lua_State *, StackValue *, int) ldo.c:627
f_call(lua_State *, void *) lapi.c:1041
luaD_rawrunprotected(lua_State *, void (*)(lua_State *, void *), void *) ldo.c:144
luaD_pcall(lua_State *, void (*)(lua_State *, void *), void *, long long, long long) ldo.c:926
lua_pcallk(lua_State *, int, int, int, long long, int (*)(lua_State *, int, long long)) lapi.c:1067
main(int, char **) lua.c:660
invoke_main() 0x00007ff7abd29909
__scrt_common_main_seh() 0x00007ff7abd297ae
__scrt_common_main() 0x00007ff7abd2966e
mainCRTStartup(void *) 0x00007ff7abd2999e
<unknown> 0x00007ffb9d0126bd
<unknown> 0x00007ffb9de2a9f8