Hi,

I found the following deadlock bug in libevent code (2.0.21). It looks that
the problem is in
bufferevent_disable that locks bufev and transitively calls
event_del_internal which waits for read callback to finish when it's not in
the main thread. Meanwhile the main thread calls bufferevent_readcb which
deadlocks on bufev.

Is it a known issue? Are there workarounds for this?

libevent thread:

#1  0x00007ffff794e672 in _L_lock_953 () from
/lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007ffff794e4da in __GI___pthread_mutex_lock (mutex=0x1031c80) at
../nptl/pthread_mutex_lock.c:114
#3  0x00007ffff771723c in _bufferevent_incref_and_lock
(bufev=bufev@entry=0x1188c00)
at bufferevent.c:582
#4  0x00007ffff771842a in bufferevent_readcb (fd=11, event=<optimized out>,
arg=0x1188c00) at bufferevent_sock.c:133
#5  0x00007ffff770df24 in event_process_active_single_queue
(activeq=0x1024640, base=0x1090000) at event.c:1350


user thread:
#0  pthread_cond_wait@@GLIBC_2.3.2 () at
../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007ffff74fdfe5 in evthread_posix_cond_wait (_cond=0x1032430,
_lock=0x1032460, tv=0x0) at evthread_pthread.c:156
#2  0x00007ffff770b9ed in event_del_internal (ev=<optimized out>) at
event.c:2220
#3  event_del (ev=ev@entry=0x1188c10) at event.c:2188
#4  0x00007ffff7718645 in be_socket_disable (bufev=0x1188c00,
event=<optimized out>) at bufferevent_sock.c:570
#5  0x00007ffff771702b in bufferevent_disable (bufev=0x1188c00,
event=<optimized out>) at bufferevent.c:505

Reply via email to