[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LuaJIT asserts on negative non-existent indexes
- From: Arseny Vakhrushev <arseny.vakhrushev@...>
- Date: Sun, 25 Apr 2010 21:54:47 +0400
Hello Mike and everyone!
I'm still playing with LuaJIT and have encountered a peculiar LuaJIT behavior.
If I call lua_is*() or lua_to*() function (lua_toboolean() or lua_touserdata() in my case) with a
negative non-existent index, assertion fails:
test2: lj_api.c:39: index2adr: Assertion `idx != 0 && -idx <= L->top - L->base' failed.
However, if I do the same with a positive but still non-existent index, assertion succeeds.
Like:
lua_State* L = luaL_newstate();
lua_toboolean(L, 10); // alright
lua_toboolean(L, -10); // <<-- assertion fails here
For lua_toboolean(), the manual states that
"It also returns 0 when called with a non-valid index."
So, I suppose I'm doing a legal thing trying to fetch a value at the end (-1) without checking a
stack size. Probably, it's not a big deal, and LuaJIT will still work fine with suppressed assertions,
but I really like this mode to make sure I do everything right.
Thanks,
Seny