Open neoxic opened 8 years ago
I must also note that I observe many repetitive compilation warnings on my system (Archlinux) such as:
In file included from /usr/include/libmongoc-1.0/mongoc-stream.h:25:0,
from /usr/include/libmongoc-1.0/mongoc-gridfs.h:26,
from /usr/include/libmongoc-1.0/mongoc-client.h:31,
from /usr/include/libmongoc-1.0/mongoc.h:27,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongoc-wrapper.h:9,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-bson.h:21,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/mongo-module.h:19,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/mongo-module.c:17:
/usr/include/libmongoc-1.0/mongoc-socket.h:96:51: warning: ‘struct addrinfo’ declared inside parameter list will not be visible outside of this definition or declaration
void mongoc_socket_inet_ntop (struct addrinfo *rp,
^~~~~~~~
/mnt/seny/Downloads/mongorover-master/c_wrapper/lua-bson.c: In function ‘_iterate_and_add_values_document_or_array_to_table’:
/mnt/seny/Downloads/mongorover-master/c_wrapper/lua-bson.c:652:36: warning: passing argument 1 of ‘bson_oid_to_string’ from incompatible pointer type [-Wincompatible-pointer-types]
bson_oid_to_string(value->value.v_oid.bytes, oid_str);
^~~~~
In file included from /usr/include/libbson-1.0/bson.h:42:0,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongoc-wrapper.h:8,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-bson.h:21,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-bson.c:17:
/usr/include/libbson-1.0/bson-oid.h:56:10: note: expected ‘const bson_oid_t * {aka const struct <anonymous> *}’ but argument is of type ‘const uint8_t * {aka const unsigned char *}’
void bson_oid_to_string (const bson_oid_t *oid,
^~~~~~~~~~~~~~~~~~
/mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongo-cursor.c: In function ‘lua_mongo_cursor_iterate’:
/mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongo-cursor.c:56:60: warning: passing argument 2 of ‘bson_document_or_array_to_table’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
throw_error = !(bson_document_or_array_to_table(L, doc, true, absolute_luaBSONObjects_index, &error));
^~~
In file included from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongo-cursor.h:21:0,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongo-cursor.c:16:
/mnt/seny/Downloads/mongorover-master/c_wrapper/lua-bson.h:55:6: note: expected ‘bson_t * {aka struct _bson_t *}’ but argument is of type ‘const bson_t * {aka const struct _bson_t *}’
bool bson_document_or_array_to_table(lua_State *L,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongo-cursor.c:57:22: warning: passing argument 1 of ‘bson_destroy’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
bson_destroy(doc);
^~~
In file included from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongoc-wrapper.h:8:0,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongo-cursor.h:20,
from /mnt/seny/Downloads/mongorover-master/c_wrapper/lua-mongo-cursor.c:16:
/usr/include/libbson-1.0/bson.h:374:1: note: expected ‘bson_t * {aka struct _bson_t *}’ but argument is of type ‘const bson_t * {aka const struct _bson_t *}’
bson_destroy (bson_t *bson);
^~~~~~~~~~~~
This makes one kind of suspicious of other hidden faults. :-)
I'll try to reproduce your LUA_USE_APICHECK
error hopefully soon. I just use pre-compiled binaries for Lua. As to the compile warnings, they should be addressed. Feel free to make a PR. I'm pretty sure it's just sticking a bunch of const
s before input parameter types. I could be completely wrong though.
It would expedite the process if you posted a snippet of code that causes the error in your first comment. Thanks.
No code snippet required. Just compile Lua 5.1 with LUA_USE_APICHECK enabled and then try to run your tests.
With Lua 5.1 compiled in development mode (-D LUA_USE_APICHECK) which is encouraged for module development, mongorover fails on opening with the following failed assertion:
Debugging it myself, I found that the stack is uncontrolled in
luaopen_mongo_module
. Please note the stack size control policy here: http://www.lua.org/manual/5.1/manual.html#3.2 It also seems odd to me that the 20 default slots are not enough for such a non-recursive function asluaopen_mongo_module()
. It looks there are too manylua_pushvalue()
's or some other issues. I believe the same applies to higher Lua versions as well.