# # # patch "lua/luaconf.h" # from [deeb01d96c697e8b212cd318fcb9ae2fccc7da6c] # to [1612dc9bfb465b4706fe1542a0917f6dd1f56ead] # # patch "lua.cc" # from [da69af522e71b86698116fa1fa7cfcc04d0ed5f0] # to [e78a6becfadc4f285ca576ae499120b9cae74873] # # patch "lua.hh" # from [b5de15e16dc12874e8dec56a883800252e05eb22] # to [b554ee40daf1764b27236a78e7e46d2f0c9332f8] # ============================================================ --- lua/luaconf.h deeb01d96c697e8b212cd318fcb9ae2fccc7da6c +++ lua/luaconf.h 1612dc9bfb465b4706fe1542a0917f6dd1f56ead @@ -449,8 +449,12 @@ ** functions. This limit is arbitrary; its only purpose is to stop C ** functions to consume unlimited stack space. */ -#define LUAI_MAXCSTACK 2048 +/* Monotone local: Newer kernels (>=2.6.23) provide unlimited argument + length and numbers, up to 2.6.22 this was the old + "limit" - ensure that we provide that at least instead + of the default 2048 */ +#define LUAI_MAXCSTACK 32767 /* ============================================================ --- lua.cc da69af522e71b86698116fa1fa7cfcc04d0ed5f0 +++ lua.cc e78a6becfadc4f285ca576ae499120b9cae74873 @@ -95,6 +95,17 @@ Lua::report_error() failed = true; } +bool +Lua::check_stack(int count) +{ + if (!lua_checkstack(st, count)) + { + fail((F("lua stack limit '%d' reached") % LUAI_MAXCSTACK).str()); + return false; + } + return true; +} + // getters Lua & @@ -251,7 +262,7 @@ Lua::begin() fail("istable() in begin"); return *this; } - I(lua_checkstack (st, 1)); + check_stack(1); lua_pushnil(st); return *this; } @@ -265,7 +276,7 @@ Lua::next() fail("istable() in next"); return false; } - I(lua_checkstack (st, 1)); + if (!check_stack(1)) return false; if (lua_next(st, -2) != 0) { return true; @@ -280,7 +291,7 @@ Lua::push_str(string const & str) Lua::push_str(string const & str) { if (failed) return *this; - I(lua_checkstack (st, 1)); + if (!check_stack(1)) return *this; lua_pushlstring(st, str.c_str(), str.size()); return *this; } @@ -289,7 +300,7 @@ Lua::push_int(int num) Lua::push_int(int num) { if (failed) return *this; - I(lua_checkstack (st, 1)); + if (!check_stack(1)) return *this; lua_pushnumber(st, num); return *this; } @@ -298,7 +309,7 @@ Lua::push_double(double num) Lua::push_double(double num) { if (failed) return *this; - I(lua_checkstack (st, 1)); + if (check_stack(1)) return *this; lua_pushnumber(st, num); return *this; } @@ -307,7 +318,7 @@ Lua::push_bool(bool b) Lua::push_bool(bool b) { if (failed) return *this; - I(lua_checkstack (st, 1)); + if (!check_stack(1)) return *this; lua_pushboolean(st, b); return *this; } @@ -316,7 +327,7 @@ Lua::push_nil() Lua::push_nil() { if (failed) return *this; - I(lua_checkstack (st, 1)); + if (!check_stack(1)) return *this; lua_pushnil(st); return *this; } @@ -325,7 +336,7 @@ Lua::push_table() Lua::push_table() { if (failed) return *this; - I(lua_checkstack (st, 1)); + if (!check_stack(1)) return *this; lua_newtable(st); return *this; } @@ -334,7 +345,7 @@ Lua::set_table(int idx) Lua::set_table(int idx) { if (failed) return *this; - I(lua_checkstack (st, 1)); + if (!check_stack(1)) return *this; lua_settable(st, idx); return *this; } @@ -351,7 +362,7 @@ Lua::call(int in, int out) Lua::call(int in, int out) { if (failed) return *this; - I(lua_checkstack (st, out)); + if (!check_stack(out)) return *this; if (lua_pcall(st, in, out, 0) != 0) { report_error(); ============================================================ --- lua.hh b5de15e16dc12874e8dec56a883800252e05eb22 +++ lua.hh b554ee40daf1764b27236a78e7e46d2f0c9332f8 @@ -28,6 +28,7 @@ Lua void fail(std::string const & reason); bool ok(); void report_error(); + bool check_stack(int count); // getters Lua & get(int idx = LUA_GLOBALSINDEX);