[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Sandboxing scripts, luaL_openlibs, and require
- From: Guy Junk <guyjunkaccount@...>
- Date: Sun, 17 May 2009 12:32:39 -0300
So, libraries are placed in the registry instead of the global table
of the current thread when I call "luaL_openlibs" or "register".
But, doesn't that mean the libraries are separate from the threads?
Why would only the first thread (script) I create get access to the
libraries and not the subsequent ones if all the libraries are in the
P.S. Can someone clarify to me how much of an overhead multiple
lua_States are exactly?
On Sun, May 17, 2009 at 11:33 AM, Patrick Donnelly <firstname.lastname@example.org> wrote:
> It is possible. Keep in mind luaL_openlibs() uses the Lua registry to
> find libraries already loaded. Because you want exclusive states, this
> is not workable. One state could modify the 'math' library causing all
> other independent states to reflect this change. I would avoid using
> that function for anything other than the main state. You should
> create a simple function that recursively copies the main state's
> global environment into the new state's global environment. You should
> also be careful of functions that use the registry in the Lua
> libraries (particularly 'require' and the package library).
> -Patrick Donnelly
> "Let all men know thee, but no man know thee thoroughly: Men freely
> ford that see the shallows."
> - Benjamin Franklin
- Sandboxing scripts, luaL_openlibs, and require, Guy Junk
- Re: Sandboxing scripts, luaL_openlibs, and require, Anner J. Bonilla
- Re: Sandboxing scripts, luaL_openlibs, and require, Guy Junk
- Re: Sandboxing scripts, luaL_openlibs, and require, Patrick Donnelly