Date: Sat, 22 Aug 2009 22:26:53 +0200 From: Robert Nagy <robert@openbsd.org> To: pgollucci@FreeBSD.org Cc: freebsd-ports@FreeBSD.org Subject: luasocket namespace clash with lighttpd mod_magnet Message-ID: <20090822202653.GA3713@bsd.hu>
next in thread | raw e-mail | index | archive | help
Hey, Basically - luasocket defines buffer_init(); which is common enough to be defined elsewhere and it is defined in mod_magnet, so you end up with a SIGSEGV. The attatched patch solves the issue by renaming the buffer_* funcs to ls_buffer_*. Its a totally safe diff that does not affect anything else and fixes a problem. I've commited this to OpenBSD already, but I need it on FreeBSD too. http://www.freebsd.org/cgi/query-pr.cgi?pr=138055 contains a wrong diff, sorry for that. Index: Makefile =================================================================== RCS file: /home/ncvs/ports/net/luasocket/Makefile,v retrieving revision 1.12 diff -u -r1.12 Makefile --- Makefile 9 Jul 2009 03:57:57 -0000 1.12 +++ Makefile 22 Aug 2009 20:25:53 -0000 @@ -7,6 +7,7 @@ PORTNAME= luasocket PORTVERSION= 2.0.2 +PORTREVISION= 1 CATEGORIES= net MASTER_SITES= http://luaforge.net/frs/download.php/2664/ PKGNAMEPREFIX= ${LUA_PKGNAMEPREFIX} Index: files/patch-config =================================================================== RCS file: /home/ncvs/ports/net/luasocket/files/patch-config,v retrieving revision 1.3 diff -u -r1.3 patch-config --- files/patch-config 28 Oct 2007 19:43:49 -0000 1.3 +++ files/patch-config 22 Aug 2009 20:25:53 -0000 @@ -1,6 +1,6 @@ ---- config.orig Sun Oct 14 12:44:03 2007 -+++ config Sun Oct 14 13:54:39 2007 -@@ -18,11 +18,13 @@ +--- config.orig 2007-10-15 06:21:05.000000000 +0200 ++++ config 2009-08-22 22:23:45.000000000 +0200 +@@ -18,11 +18,13 @@ UNIX_SO=unix.$(EXT) #LUAINC=-I/usr/local/include/lua50 #LUAINC=-I/usr/local/include/lua5.1 #LUAINC=-Ilua-5.1.1/src @@ -14,7 +14,7 @@ #------ # Top of your Lua installation -@@ -30,11 +32,11 @@ +@@ -30,11 +32,11 @@ UNIX_SO=unix.$(EXT) # #INSTALL_TOP_SHARE=/usr/local/share/lua/5.0 #INSTALL_TOP_LIB=/usr/local/lib/lua/5.0 @@ -30,7 +30,7 @@ #------ # Compiler and linker settings -@@ -49,11 +51,11 @@ +@@ -49,11 +51,11 @@ INSTALL_EXEC=cp #------ # Compiler and linker settings # for Linux Index: files/patch-src_buffer_c =================================================================== RCS file: files/patch-src_buffer_c diff -N files/patch-src_buffer_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-src_buffer_c 22 Aug 2009 20:25:53 -0000 @@ -0,0 +1,100 @@ +$OpenBSD: patch-src_buffer_c,v 1.1 2005/11/25 15:09:44 pedro Exp $ +--- src/buffer.c.orig 2007-10-15 06:21:05.000000000 +0200 ++++ src/buffer.c 2009-08-22 22:25:16.000000000 +0200 +@@ -33,7 +33,7 @@ static int sendraw(p_buffer buf, const c + /*-------------------------------------------------------------------------*\ + * Initializes module + \*-------------------------------------------------------------------------*/ +-int buffer_open(lua_State *L) { ++int ls_buffer_open(lua_State *L) { + (void) L; + return 0; + } +@@ -41,7 +41,7 @@ int buffer_open(lua_State *L) { + /*-------------------------------------------------------------------------*\ + * Initializes C structure + \*-------------------------------------------------------------------------*/ +-void buffer_init(p_buffer buf, p_io io, p_timeout tm) { ++void ls_buffer_init(p_buffer buf, p_io io, p_timeout tm) { + buf->first = buf->last = 0; + buf->io = io; + buf->tm = tm; +@@ -52,7 +52,7 @@ void buffer_init(p_buffer buf, p_io io, + /*-------------------------------------------------------------------------*\ + * object:getstats() interface + \*-------------------------------------------------------------------------*/ +-int buffer_meth_getstats(lua_State *L, p_buffer buf) { ++int ls_buffer_meth_getstats(lua_State *L, p_buffer buf) { + lua_pushnumber(L, buf->received); + lua_pushnumber(L, buf->sent); + lua_pushnumber(L, timeout_gettime() - buf->birthday); +@@ -62,7 +62,7 @@ int buffer_meth_getstats(lua_State *L, p + /*-------------------------------------------------------------------------*\ + * object:setstats() interface + \*-------------------------------------------------------------------------*/ +-int buffer_meth_setstats(lua_State *L, p_buffer buf) { ++int ls_buffer_meth_setstats(lua_State *L, p_buffer buf) { + buf->received = (long) luaL_optnumber(L, 2, buf->received); + buf->sent = (long) luaL_optnumber(L, 3, buf->sent); + if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4); +@@ -73,14 +73,16 @@ int buffer_meth_setstats(lua_State *L, p + /*-------------------------------------------------------------------------*\ + * object:send() interface + \*-------------------------------------------------------------------------*/ +-int buffer_meth_send(lua_State *L, p_buffer buf) { ++int ls_buffer_meth_send(lua_State *L, p_buffer buf) { + int top = lua_gettop(L); + int err = IO_DONE; + size_t size = 0, sent = 0; + const char *data = luaL_checklstring(L, 2, &size); + long start = (long) luaL_optnumber(L, 3, 1); + long end = (long) luaL_optnumber(L, 4, -1); ++#ifdef LUASOCKET_DEBUG + p_timeout tm = timeout_markstart(buf->tm); ++#endif + if (start < 0) start = (long) (size+start+1); + if (end < 0) end = (long) (size+end+1); + if (start < 1) start = (long) 1; +@@ -106,12 +108,14 @@ int buffer_meth_send(lua_State *L, p_buf + /*-------------------------------------------------------------------------*\ + * object:receive() interface + \*-------------------------------------------------------------------------*/ +-int buffer_meth_receive(lua_State *L, p_buffer buf) { ++int ls_buffer_meth_receive(lua_State *L, p_buffer buf) { + int err = IO_DONE, top = lua_gettop(L); + luaL_Buffer b; + size_t size; + const char *part = luaL_optlstring(L, 3, "", &size); ++#ifdef LUASOCKET_DEBUG + p_timeout tm = timeout_markstart(buf->tm); ++#endif + /* initialize buffer with optional extra prefix + * (useful for concatenating previous partial results) */ + luaL_buffinit(L, &b); +@@ -149,7 +153,7 @@ int buffer_meth_receive(lua_State *L, p_ + /*-------------------------------------------------------------------------*\ + * Determines if there is any data in the read buffer + \*-------------------------------------------------------------------------*/ +-int buffer_isempty(p_buffer buf) { ++int ls_buffer_isempty(p_buffer buf) { + return buf->first >= buf->last; + } + +@@ -244,7 +248,7 @@ static int recvline(p_buffer buf, luaL_B + static void buffer_skip(p_buffer buf, size_t count) { + buf->received += count; + buf->first += count; +- if (buffer_isempty(buf)) ++ if (ls_buffer_isempty(buf)) + buf->first = buf->last = 0; + } + +@@ -256,7 +260,7 @@ static int buffer_get(p_buffer buf, cons + int err = IO_DONE; + p_io io = buf->io; + p_timeout tm = buf->tm; +- if (buffer_isempty(buf)) { ++ if (ls_buffer_isempty(buf)) { + size_t got; + err = io->recv(io->ctx, buf->data, BUF_SIZE, &got, tm); + buf->first = 0; Index: files/patch-src_buffer_h =================================================================== RCS file: files/patch-src_buffer_h diff -N files/patch-src_buffer_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-src_buffer_h 22 Aug 2009 20:25:53 -0000 @@ -0,0 +1,23 @@ +$OpenBSD$ +--- src/buffer.h.orig Thu Apr 27 05:23:22 2006 ++++ src/buffer.h Sat Aug 22 22:19:02 2009 +@@ -36,12 +36,12 @@ typedef struct t_buffer_ { + } t_buffer; + typedef t_buffer *p_buffer; + +-int buffer_open(lua_State *L); +-void buffer_init(p_buffer buf, p_io io, p_timeout tm); +-int buffer_meth_send(lua_State *L, p_buffer buf); +-int buffer_meth_receive(lua_State *L, p_buffer buf); +-int buffer_meth_getstats(lua_State *L, p_buffer buf); +-int buffer_meth_setstats(lua_State *L, p_buffer buf); +-int buffer_isempty(p_buffer buf); ++int ls_buffer_open(lua_State *L); ++void ls_buffer_init(p_buffer buf, p_io io, p_timeout tm); ++int ls_buffer_meth_send(lua_State *L, p_buffer buf); ++int ls_buffer_meth_receive(lua_State *L, p_buffer buf); ++int ls_buffer_meth_getstats(lua_State *L, p_buffer buf); ++int ls_buffer_meth_setstats(lua_State *L, p_buffer buf); ++int ls_buffer_isempty(p_buffer buf); + + #endif /* BUF_H */ Index: files/patch-src_luasocket_c =================================================================== RCS file: files/patch-src_luasocket_c diff -N files/patch-src_luasocket_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-src_luasocket_c 22 Aug 2009 20:25:53 -0000 @@ -0,0 +1,11 @@ +--- src/luasocket.c.orig 2007-10-15 06:21:05.000000000 +0200 ++++ src/luasocket.c 2009-08-22 22:23:45.000000000 +0200 +@@ -51,7 +51,7 @@ static const luaL_reg mod[] = { + {"auxiliar", auxiliar_open}, + {"except", except_open}, + {"timeout", timeout_open}, +- {"buffer", buffer_open}, ++ {"buffer", ls_buffer_open}, + {"inet", inet_open}, + {"tcp", tcp_open}, + {"udp", udp_open}, Index: files/patch-src_tcp_c =================================================================== RCS file: files/patch-src_tcp_c diff -N files/patch-src_tcp_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-src_tcp_c 22 Aug 2009 20:25:53 -0000 @@ -0,0 +1,57 @@ +$OpenBSD$ +--- src/tcp.c.orig Thu Apr 27 05:23:21 2006 ++++ src/tcp.c Sat Aug 22 22:19:02 2009 +@@ -104,22 +104,22 @@ int tcp_open(lua_State *L) + \*-------------------------------------------------------------------------*/ + static int meth_send(lua_State *L) { + p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); +- return buffer_meth_send(L, &tcp->buf); ++ return ls_buffer_meth_send(L, &tcp->buf); + } + + static int meth_receive(lua_State *L) { + p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); +- return buffer_meth_receive(L, &tcp->buf); ++ return ls_buffer_meth_receive(L, &tcp->buf); + } + + static int meth_getstats(lua_State *L) { + p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); +- return buffer_meth_getstats(L, &tcp->buf); ++ return ls_buffer_meth_getstats(L, &tcp->buf); + } + + static int meth_setstats(lua_State *L) { + p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); +- return buffer_meth_setstats(L, &tcp->buf); ++ return ls_buffer_meth_setstats(L, &tcp->buf); + } + + /*-------------------------------------------------------------------------*\ +@@ -152,7 +152,7 @@ static int meth_setfd(lua_State *L) + static int meth_dirty(lua_State *L) + { + p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); +- lua_pushboolean(L, !buffer_isempty(&tcp->buf)); ++ lua_pushboolean(L, !ls_buffer_isempty(&tcp->buf)); + return 1; + } + +@@ -176,7 +176,7 @@ static int meth_accept(lua_State *L) + io_init(&clnt->io, (p_send) socket_send, (p_recv) socket_recv, + (p_error) socket_ioerror, &clnt->sock); + timeout_init(&clnt->tm, -1, -1); +- buffer_init(&clnt->buf, &clnt->io, &clnt->tm); ++ ls_buffer_init(&clnt->buf, &clnt->io, &clnt->tm); + return 1; + } else { + lua_pushnil(L); +@@ -329,7 +329,7 @@ static int global_create(lua_State *L) + io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv, + (p_error) socket_ioerror, &tcp->sock); + timeout_init(&tcp->tm, -1, -1); +- buffer_init(&tcp->buf, &tcp->io, &tcp->tm); ++ ls_buffer_init(&tcp->buf, &tcp->io, &tcp->tm); + return 1; + } else { + lua_pushnil(L); Index: files/patch-src_unix_c =================================================================== RCS file: files/patch-src_unix_c diff -N files/patch-src_unix_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-src_unix_c 22 Aug 2009 20:25:53 -0000 @@ -0,0 +1,57 @@ +$OpenBSD$ +--- src/unix.c.orig Thu Apr 27 05:23:21 2006 ++++ src/unix.c Sat Aug 22 22:19:02 2009 +@@ -105,22 +105,22 @@ int luaopen_socket_unix(lua_State *L) { + \*-------------------------------------------------------------------------*/ + static int meth_send(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); +- return buffer_meth_send(L, &un->buf); ++ return ls_buffer_meth_send(L, &un->buf); + } + + static int meth_receive(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); +- return buffer_meth_receive(L, &un->buf); ++ return ls_buffer_meth_receive(L, &un->buf); + } + + static int meth_getstats(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); +- return buffer_meth_getstats(L, &un->buf); ++ return ls_buffer_meth_getstats(L, &un->buf); + } + + static int meth_setstats(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); +- return buffer_meth_setstats(L, &un->buf); ++ return ls_buffer_meth_setstats(L, &un->buf); + } + + /*-------------------------------------------------------------------------*\ +@@ -149,7 +149,7 @@ static int meth_setfd(lua_State *L) { + + static int meth_dirty(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); +- lua_pushboolean(L, !buffer_isempty(&un->buf)); ++ lua_pushboolean(L, !ls_buffer_isempty(&un->buf)); + return 1; + } + +@@ -172,7 +172,7 @@ static int meth_accept(lua_State *L) { + io_init(&clnt->io, (p_send)socket_send, (p_recv)socket_recv, + (p_error) socket_ioerror, &clnt->sock); + timeout_init(&clnt->tm, -1, -1); +- buffer_init(&clnt->buf, &clnt->io, &clnt->tm); ++ ls_buffer_init(&clnt->buf, &clnt->io, &clnt->tm); + return 1; + } else { + lua_pushnil(L); +@@ -346,7 +346,7 @@ static int global_create(lua_State *L) { + io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv, + (p_error) socket_ioerror, &un->sock); + timeout_init(&un->tm, -1, -1); +- buffer_init(&un->buf, &un->io, &un->tm); ++ ls_buffer_init(&un->buf, &un->io, &un->tm); + return 1; + } else { + lua_pushnil(L);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090822202653.GA3713>