active index mismatch in heap?

Brandon Black blblack at
Sun Feb 27 06:27:10 CET 2011

I'm getting the following assert() failure rarely when running with
libev 4.04 w/ EV_VERIFY=3 (this on Linux w/ epoll, a multi-threaded
app that uses one loop per thread).  I haven't yet managed to catch
the assert while running under a debugger, it only seems to happen
when I'm running a "live" test daemon (I made it so that assert()
output would go to syslog), and even then it's only happened twice in
the course of a week or so:

Assertion '("libev: active index mismatch in heap", ((W)((heap
[i]).w))->active == i)' failed in verify_heap() at ./libev/ev.c:1978

At this point I'm just looking for some pointers to help me track down
what's going on: is this generally likely to be an application bug on
my part (I am using the public API only), or should I be looking more
at libev itself?  I'd post code but the application is rather complex
and I haven't been able to reliably reproduce this even with the full
app, much less pare it down to a minimal case yet.  In general I'm
only using normal ev_timer, not ev_periodic.  Some of my timers are
short one-shot timers, and then there's one repeating timer which is
reset to a new interval with w->repeat = X; ev_timer_again() within
its callback (as part of a double-linked list setup like strategy #4
in ev.pod).

Is there some likely stupid error I could be making in my use of the
ev_timer API that would lead to this assert, that I could double-check
the code for specifically?

-- Brandon

More information about the libev mailing list