[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Deadlock driving me nuts



I'm willing to post code snippets if it helps.

What I'm seeing is that after some time adding just 1 event causes an infinite loop in evmap_io_active, and I can't figure out if I'm doing anything wrong, and why the code would work for some time then go crazy.

Thanks

Sherif

On Sun, Apr 10, 2011 at 11:56 AM, Sherif Fanous <sherif.fanous@xxxxxxxxx> wrote:
Ok I managed to get some more info

It deadlocked and this is what I got in my log file

10/04/11 11:27:09  1466 3035069296 1 events are added to the send event base
10/04/11 11:27:09  1425 3068124016 Dispatching send event base
10/04/11 11:27:09  1425 3068124016 Starting loop for base 0x8808ad0
10/04/11 11:27:09  1425 3068124016 base: 0x8808ad0, ev: 0xb13f00f8
10/04/11 11:27:09  1425 3068124016 base: 0x8808ad0, ev: 0xb13f00f8

The last line repeats to infinity.

On Sun, Apr 10, 2011 at 11:00 AM, Sherif Fanous <sherif.fanous@xxxxxxxxx> wrote:
Sorry about the late reply.

I'm not very good with gdb. Actually I'm just a beginner with gdb.

To generate the above trace I first waited for a deadlock to occur. I then killed the process using "kill -6 <pid>" to force the process to dump core. I then opened the core file using gdb and ran the command "thread apply all where"

I'll try to figure out how it's done, if not I'll just add some log messages to evmap.c to log the values of base & ev on each loop and just use event_set_log_callback to log this to a file :S

Thanks

Sherif

On Sat, Apr 9, 2011 at 2:58 PM, Nick Mathewson <nickm@xxxxxxxxxxxxx> wrote:
On Sat, Apr 9, 2011 at 4:16 AM, Sherif Fanous <sherif.fanous@xxxxxxxxx> wrote:
> As a matter of fact, the thread in question is usually stuck in
> event_active_nolock.
> The funny thing is that it shows that it's stuck in line 2212 in event.c
> which is the opening brace of the function.
> How would I walk through ctx->events?

So, having a look at the TAILQ_FOREACH definition, it's going to unpack to:

   for (ev = TAILQ_FIRST(&ctx->events);
       ev != TALQ_END(&ctx->events);
       ev = TAILQ_NEXT(ev, ev_io_next) {

and that's going to turn into:

   for (ev = ctx->events.tqh_first;
       ev != NULL;
       ev = ev->ev_io_next.tqe_next) {

So, given those stack traces, I assume you're using gdb.  Start with
ctx->events.tqh_first, then look at the ev_io_next.tqe_next field of
that, then the ev_io_next.tqe_next field of that, etc, until you get a
repeat or a NULL or something that looks crazy.

hth,
--
Nick