[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Missing error message in panic handler / calling luaD_throw without error message on stack
- From: Jan Behrens <jbe-lua-l@...>
- Date: Sun, 9 Nov 2014 17:14:44 +0100
Hello,
I'm limiting the memory consumption of a Lua machine using a special
memory allocator (of type lua_Alloc) that will refuse to allocate more
than a certain amount of memory by returning a NULL pointer when too
much memory has been consumed.
Doing this, I stumbled upon some odd behavior of the panic handler
mechanism in Lua 5.2.3:
If lua_newuserdata() fails to allocate memory and no pcall/xpcall is
active, then the panic handler will be called without pushing an error
message on top of the stack (i.e. the value that has been on top of the
stack prior to the lua_newuserdata() call will be where the error
message ought to be).
Is this behavior intended?
Looking into the source code of Lua 5.2.3, I found that in line #93 of
lmem.c, the function luaD_throw(L, LUA_ERRMEM) is called without
pushing first an error message on top of the stack. Other calls of
luaD_throw, however, push an error message to the stack, e.g. function
lexerror() in llex.c, line #110 or function checkmode() in ldo.c,
line #635.
Is this a bug?
Kind Regards
Jan Behrens
--
Public Software Group e. V.
Johannisstr. 12, 10117 Berlin, Germany
www.public-software-group.org
vorstand at public-software-group.org
eingetragen in das Vereinregister
des Amtsgerichtes Charlottenburg
Registernummer: VR 28873 B
Vorstände (einzelvertretungsberechtigt):
Jan Behrens
Axel Kistner
Andreas Nitsche
Björn Swierczek