[Libevent-users] libevent 1.2 varargs bug

2006-11-28 Thread AnToXa
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 [ [EMAIL PROTECTED] ] [ ICQ: 85431470 ]

vprintf_va_args.patch
Description: Binary data
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users


[Libevent-users] SIGCHLD handling problems

2006-09-20 Thread AnToXa
Hello,

I'm using libevent for signal handling extensively and noticed a
slight problem: signals are (re)set every time you enter event_base_loop()
and the problem code is:

event_init();
// install handler for SIHCHLD with signal_set/signal_add
// fork a child process
event_dispatch();

the posix standard says:
http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html [^]
If a process establishes a signal-catching function for the SIGCHLD signal 
while it has a terminated
 child process for which it has not waited, it is unspecified whether a SIGCHLD 
signal is generated 
to indicate that child process.

and therefore if child process exits before you enter event_dispatch()
you may not get SIGCHLD at all.

the workaround i use is: install signal event, install the event that fires 1ms 
after
entering event loop and in callback fork the process. but it's ugly.

is there a good reason for such behaviour except simplicity?
should i submit a bug report or a patch ? :)

-- 
Anton Povarov [ [EMAIL PROTECTED] ] [ ICQ: 85431470 ]

___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users