That is weird. The number of frames should be 2*n: for each module,
it needs one frame for 'require' and one frame for the module itself.
I tested with 10 nested modules (which used 20 frames) and did not
find any problem.
The following bash script results in this output:
---
1
2
3
4
5
PANIC: unprotected error in call to Lua API (C stack overflow)
---
With Lua 5.3 it goes up to 197 when there are enough t*-files.
Bash-Script:
LUA_DIR=...
mkdir tmp
cd tmp
for no in $(seq 1 10); do
cat > t$no.lua <<EOF
print( "$no" )
require "t$(($no+1))"
EOF
done
cat > t.c <<EOF
#include <lua.h>
#include <lauxlib.h>
int main( int argc, char** argv )
{
lua_State* Lg = luaL_newstate();
luaL_openlibs( Lg );
lua_State* L = lua_newthread( Lg );
lua_rawgeti( L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS );
lua_getfield( L, -1, "require" );
lua_pushstring( L, "t1" );
lua_call( L, 1, 0 );
return 0;
}
EOF
gcc t.c -o t -I$LUA_DIR/include $LUA_DIR/lib/liblua.a -lm -ldl
./t