lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi

I am still stressing Lua under low memory, failing malloc in various scenarios.

I noticed different functions exit with different error messages and exit codes.
Examples:

lstring.c: LUA_YIELD : "not enough memory"
lauxlib.c: LUA_ERRRUN : "test.lua:10: not enough memory for buffer allocation"
lstrlib.c: LUA_ERRRUN : "test.lua:11: resulting string too large"


I am surprised
- the functions return different status
- none of the with the exit code LUA_ERRMEM !

From my experience with other libraries, this isn't optimal IMHO.

I have to check all these possibilities instead of a simple, concise and immediately readable

ret = lua_api(L, ...);
if (ret == LUA_ERRMEM)


At the moment I written very ugly code.
For example for the lstring.c functions: I get the error message and

if (ret != 0 && ptr == MEMERRMSG)
    ret = LUA_ERRMEM;

(that error message is defined into lstring.h

#define MEMERRMSG       "not enough memory"
)


Have you already discussed about the possibility to uniform the exit codes from the Lua builtin libraries?
What about - at least - return LUA_ERRMEM when the basic APIs fail due to memory exhaustion?

M