Crash in assert
edubart opened this issue · 6 comments
This is odd, this library works fine when running a script, but when I use it in combination with busted
and many test files it crashes with:
lua5.3: src/luazen.c:55: llib_append: Assertion `llib_top < LT_SIZE' failed.
Aborted (core dumped)
The only code in my tests files is a simple require
:
local lz = require 'luazen'
Oh I get why, busted
sets all package.loaded
to nil when a test unit finishes, so luaopen_luazen
will be called again for each require
in different test suits.
In case you don't know, busted
is a popular unit testing for lua. https://github.com/Olivine-Labs/busted
In case you fix this please upload the latest rockspec to luarocks so we can depend on it. The latest version on luarocks is old, "0.9-11 year ago".
A simple fix is this:
diff --git a/src/luazen.c b/src/luazen.c
index 5c60453..828a73d 100644
--- a/src/luazen.c
+++ b/src/luazen.c
@@ -71,6 +71,7 @@ static int llib_append(const char *fname, lua_CFunction func) {
llib_append(#NAME, ll_ ## NAME);
static void llib_init() {
+ llib_top = 0;
// luazen function declarations - comment APPEND lines to
// remove functions from the luazen build
//
Thanks for the heads up and for the diagnostic. Will fix it ASAP.
Oh I get why,
busted
sets allpackage.loaded
to nil when a test unit finishes, soluaopen_luazen
will be called again for eachrequire
in different test suits.In case you don't know,
busted
is a popular unit testing for lua. https://github.com/Olivine-Labs/busted
I have heard about busted, but never used it. I will look into it. Thanks.
Closing because you have fixed on master.