luaL_newstate in Lua 5.4

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

luaL_newstate in Lua 5.4

actboy168@gmail.com
To quote from the reference manual :

> luaL_newstate [-0, +0, –]
> Returns the new state, or NULL if there is a memory allocation error.

But now luaL_openlibs will call lua_newuserdatauv and luaL_ref, and then they have a chance to raise a memory error.

-- actboy168
Reply | Threaded
Open this post in threaded view
|

Re: luaL_newstate in Lua 5.4

Andrew Gierth
>>>>> "actboy168" == actboy168  <[hidden email]> writes:

 > To quote from the reference manual :
 >> luaL_newstate [-0, +0, –]
 >> Returns the new state, or NULL if there is a memory allocation error.

 actboy168> But now luaL_openlibs

I assume you meant luaL_newstate?

 actboy168> will call lua_newuserdatauv and luaL_ref, and then they have
 actboy168> a chance to raise a memory error.

Yes. This is just another rough edge from the poorly-thought-out
warnings system: if there's enough memory to allocate a state, but not
enough to allocate a (full) userdata and luaL_ref it, then the panic
function will be called leading to an abort().

--
Andrew.
Reply | Threaded
Open this post in threaded view
|

Re: luaL_newstate in Lua 5.4

Roberto Ierusalimschy
In reply to this post by actboy168@gmail.com
> To quote from the reference manual :
>
> > luaL_newstate [-0, +0, –]
> > Returns the new state, or NULL if there is a memory allocation error.
>
> But now luaL_openlibs will call lua_newuserdatauv and luaL_ref, and then
> they have a chance to raise a memory error.

Thanks for the report.

-- Roberto