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

Re: [Libevent-users] Simple question about multithreading SSL bufferevents.



On Wed, Mar 27, 2013 at 5:06 PM, John <jjchnk-libevent@xxxxxxxxx> wrote:
> You can see the test code at
>
> http://pastebin.com/0136vEbe
>

Yup, that's a deadlock.  Reproducible too. Thanks!

The main thread got stuck in

#0  0x00000030c8c0de4d in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00000030c8c09cc1 in _L_lock_885 () from /lib64/libpthread.so.0
#2  0x00000030c8c09bda in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x0000000000409dd8 in bufferevent_incref_and_lock_ (
    bufev=bufev@entry=0x20085a0) at bufferevent.c:616
#4  0x000000000041d10b in be_openssl_writeeventcb (fd=<optimized out>, what=4,
    ptr=0x20085a0) at bufferevent_openssl.c:943
#5  0x0000000000411144 in event_process_active_single_queue (
    base=base@entry=0x2007790, activeq=0x2007a40,
    max_to_process=max_to_process@entry=2147483647, endtime=endtime@entry=0x0)
    at event.c:1461
#6  0x000000000041184f in event_process_active (base=0x2007790) at event.c:1528
#7  event_base_loop (base=0x2007790, flags=0) at event.c:1751
#8  0x0000000000403cb1 in main ()

Most other threads are stuck in:

#0  0x00000030c8c0de4d in __lll_lock_wait () from /lib64/libpthread.so.0
(gdb) bt
#0  0x00000030c8c0de4d in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00000030c8c09ca6 in _L_lock_836 () from /lib64/libpthread.so.0
#2  0x00000030c8c09ba8 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x00000000004034e8 in run_thread ()
#4  0x00000030c8c07d15 in start_thread () from /lib64/libpthread.so.0
#5  0x00000030c80f246d in clone () from /lib64/libc.so.6

Except for one thread, which is stuck in:

#0  0x00000030c8c0b5e5 in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib64/libpthread.so.0
#1  0x000000000041da35 in evthread_posix_cond_wait (lock_=0x2007a60,
    cond_=0x2007a90, tv=<optimized out>) at evthread_pthread.c:158
#2  evthread_posix_cond_wait (cond_=0x2007a90, lock_=0x2007a60, tv=0x0)
    at evthread_pthread.c:137
#3  0x000000000040f786 in event_del_nolock_ (ev=ev@entry=0x2008630)
    at event.c:2385
#4  0x000000000040f8ee in event_del (ev=0x2008630) at event.c:2352
#5  0x0000000000404115 in evbuffer_run_callbacks (buffer=0x2008870,
    running_deferred=<optimized out>) at buffer.c:500
#6  0x00000000004066a8 in evbuffer_add (buf=0x2008870, data_in=0x7fc920f82d60,
    datlen=35) at buffer.c:1781
#7  0x0000000000409930 in bufferevent_write (bufev=<optimized out>,
    data=<optimized out>, size=<optimized out>) at bufferevent.c:413
#8  0x0000000000403504 in run_thread ()
#9  0x00000030c8c07d15 in start_thread () from /lib64/libpthread.so.0
#10 0x00000030c80f246d in clone () from /lib64/libc.so.6

This looks just like the deadlock discussed on that other thread (the
one with with subject "Deadlock when calling bufferevent_free from an
other thread" -- have a look at the archives for more info on the
status of that one.)

(Wow, I should really answer that thread RSN.)

-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.