[Libevent-users] libevent 1.2 varargs bug
AnToXa
anton.povarov at gmail.com
Tue Nov 28 07:28:10 EST 2006
Hello.
i've been trying to 'make verify' libevent-1.2 on x86-64 SLES9 (gcc 3.3.3, glibc
2.3.5 (20050720) ) system.
it just segfaults on regress evbuffer test, i've tracked the issue down to
the loop calling vsnprintf() inside evbuffer_add_vprintf()
the problem is that you can't call vsnprintf() many times with the same va_list
it just segfaults on the second call, the glibc documentation states the
following:
http://www.gnu.org/software/libc/manual/html_node/Variable-Arguments-Output.html#Variable-Arguments-Output
In some other systems, the va_list pointer may become invalid after the call to vprintf,
so you must not use va_arg after you call vprintf. Instead, you should call va_end
to retire the pointer from service. However, you can safely call va_start on another
pointer variable and begin fetching the arguments again through that pointer.
Calling vprintf does not destroy the argument list of your function,
merely the particular pointer that you passed to it.
i suggest using va_copy()-ing ap every time you enter the loop.
proposed patch is attached, successfuly tested on x86, x86-64 SLES9.
--
Anton Povarov [ anton.povarov at gmail.com ] [ ICQ: 85431470 ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vprintf_va_args.patch
Type: application/octet-stream
Size: 986 bytes
Desc: not available
Url : http://monkeymail.org/archives/libevent-users/attachments/20061128/2401ee8d/vprintf_va_args-0001.obj
More information about the Libevent-users
mailing list