I submitted a fix along these lines to subversion. Please, check it out and see if you can reproduce problems on amd64. I don't have access to such a system.
Thank you, Niels. On 10/27/06, Alejo Sanchez <[EMAIL PROTECTED]> wrote:
Hi Niels, list. I'm using libevent on a Gentoo GNU/Linux on amd64. The regression test for Evbuffer segfaulted and checking the code evbuffer_add_vprintf() does multiple calls always to a va_list (as the evbuffer is created without a buffer and there's a try t o vsprintf() to a null one) According to this guy http://lists.freebsd.org/pipermail/freebsd-amd64/2005-February/003630.html you can only do a call to a va_list and you have to reinitialize it afterwards. So I guess there should be a va_list and a call to va_copy inside evbuffer_add_vprintf() The patch below works but not sure if it's the best way to do it. Have a nice weekend :) Alejo --- buffer.c.ori 2006-10-27 17:22:18.000000000 +0100 +++ buffer.c 2006-10-27 17:27:08.000000000 +0100 @@ -132,17 +132,23 @@ size_t space; size_t oldoff = buf->off; int sz; + va_list aq; for (;;) { buffer = buf->buffer + buf->off; space = buf->totallen - buf->misalign - buf->off; + va_copy(aq, ap); + #ifdef WIN32 - sz = vsnprintf(buffer, space - 1, fmt, ap); + sz = vsnprintf(buffer, space - 1, fmt, aq); buffer[space - 1] = '\0'; #else - sz = vsnprintf(buffer, space, fmt, ap); + sz = vsnprintf(buffer, space, fmt, aq); #endif + + va_end(aq); + if (sz == -1) return (-1); if (sz < space) { int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap) { char *buffer; size_t space; size_t oldoff = buf->off; int sz; for (;;) { buffer = buf->buffer + buf->off; space = buf->totallen - buf->misalign - buf->off; #ifdef WIN32 sz = vsnprintf(buffer, space - 1, fmt, ap); buffer[space - 1] = '\0'; #else sz = vsnprintf(buffer, space, fmt, ap); #endif if (sz == -1) return (-1); if (sz < space) { buf->off += sz; if (buf->cb != NULL) (*buf->cb)(buf, oldoff, buf->off, buf->cbarg); return (sz); } if (evbuffer_expand(buf, sz + 1) == -1) return (-1); } /* NOTREACHED */ } _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users
_______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users