[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Assertion error + Segmentation Fault
On Thu, Apr 8, 2010 at 7:46 AM, Sherif Fanous <sherif.fanous@xxxxxxxxx> wrote:
> Hi
> I am using libevent 2.0.4 alpha in my C application.
> The below snapshot of my code occasionally encounters the following 2
> problems
>
> [err] event.c:1961: Assertion !(ev->ev_flags & ~EVLIST_ALL) failed in
> event_del_internal
> Aborted
> Segmentation Fault. I've traced down that it occurs in the event_base_loop
> call
>
> In a nutshell, I have a linked list of servers. I loop through every server,
> if I'm connected to that server then I create an event for the socket. I
> then run the event loop with a timeout. I use the timeout to break out of
> the event loop and check if the termination condition has been encountered
> in another thread. I also run the event loop with EVLOOP_ONCE to break out
> of the loop as soon as 1 event triggers to re-evaluate the linked list of
> servers (new connections established, current connections terminated, ...)
> When I break of the event loop, I delete the events and free them.
> Can anyone please tell me what I'm doing wrong here? Is it an internal
> libevent problem, or is my code messing up somewhere?
Try running 2.0.5-beta with the debugging options. (That is, call
event_enable_debug_mode() before any other libevent call.)
I think the problem in the code you posted might be that your cleanup
loop is calling event_del() and event_free() on every event[i], but
your setup loop is only setting event[i] if
servers_array[i]->is_socket_connected. This will make some of the
entries in event[i] be uninitialized, which will make event_del() very
unhappy.
[Also, fwiw, the code you posted is going to be pretty inefficient: it
loops over all the servers every time you call the event loop, so it's
going to be O(N) in the number of servers, even if you're on an OS
with an efficient O(1) backend for Libevent to use.]
hth,
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.