Hi I found a deadlock which occurs when resolving STUN server: (gdb) info thread 3 Thread 0x7f3b13a87700 (LWP 6129) 0x00007f3b1bdf020d in nanosleep () at ../sysdeps/unix/syscall-template.S:82 2 Thread 0x7f3b17674700 (LWP 6130) __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136 * 1 Thread 0x7f3b1d63b740 (LWP 6124) __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136 (gdb) thread 1 [Switching to thread 1 (Thread 0x7f3b1d63b740 (LWP 6124))]#0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136 136 in ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S (gdb) bt #0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136 #1 0x00007f3b1c98f864 in _L_lock_1024 () from /lib/libpthread.so.0 #2 0x00007f3b1c98f6c7 in __pthread_mutex_lock (mutex=0xdcb500) at pthread_mutex_lock.c:82 #3 0x0000000000546a92 in pj_mutex_lock (mutex=0xdcb500) at ../src/pj/os_core_unix.c:1214 #4 0x0000000000542c39 in ioqueue_dispatch_read_event (ioqueue=0xdca8e0, h=0xdcb3b8) at ../src/pj/ioqueue_common_abs.c:400 #5 0x0000000000544fc0 in pj_ioqueue_poll (ioqueue=0xdca8e0, timeout=0x7fff5fa379e0) at ../src/pj/ioqueue_select.c:902 #6 0x000000000045ce8a in pjsip_endpt_handle_events2 (endpt=0xdbfb48, max_timeout=0x7fff5fa37a20, p_count=0x7fff5fa37a3c) at ../src/pjsip/sip_endpoint.c:719 #7 0x00000000004259f8 in pjsua_handle_events (msec_timeout=10) at ../src/pjsua-lib/pjsua_core.c:1510 #8 0x000000000042535c in resolve_stun_server (wait=1) at ../src/pjsua-lib/pjsua_core.c:1258 #9 0x0000000000425b7f in create_sip_udp_sock (af=2, cfg=0x7e0408, p_sock=0x7fff5fa37cb8, p_pub_addr=0x7fff5fa37d50) at ../src/pjsua-lib/pjsua_core.c:1612 #10 0x0000000000426274 in pjsua_transport_create (type=PJSIP_TRANSPORT_UDP, cfg=0x7e0408, p_id=0x7fff5fa37fcc) at ../src/pjsua-lib/pjsua_core.c:1791 #11 0x0000000000411c59 in app_init (argc=2, argv=0x7fff5fa38228) at ../src/pjsua/pjsua_app.c:4827 #12 0x0000000000406fb4 in main (argc=2, argv=0x7fff5fa38228) at ../src/pjsua/main.c:82 (gdb) thread 2 [Switching to thread 2 (Thread 0x7f3b17674700 (LWP 6130))]#0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136 136 in ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S (gdb) bt #0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136 #1 0x00007f3b1c98f864 in _L_lock_1024 () from /lib/libpthread.so.0 #2 0x00007f3b1c98f6c7 in __pthread_mutex_lock (mutex=0xdbf738) at pthread_mutex_lock.c:82 #3 0x0000000000546a92 in pj_mutex_lock (mutex=0xdbf738) at ../src/pj/os_core_unix.c:1214 #4 0x00000000004246a0 in destroy_stun_resolve (sess=0xdd6b18) at ../src/pjsua-lib/pjsua_core.c:952 #5 0x00000000004248ab in stun_resolve_complete (sess=0xdd6b18) at ../src/pjsua-lib/pjsua_core.c:990 #6 0x0000000000424ab3 in test_stun_on_status (stun_sock=0xdd6d38, op=PJ_STUN_SOCK_BINDING_OP, status=0) at ../src/pjsua-lib/pjsua_core.c:1035 #7 0x00000000004d0b6c in sess_on_request_complete (sess=0xdd7f68, status=0, token=0x1, tdata=0xdd9ea8, response=0xdd87c8, src_addr=0xdd7a40, src_addr_len=16) at ../src/pjnath/stun_sock.c:705 #8 0x00000000004cd1e0 in stun_tsx_on_complete (tsx=0xdda028, status=0, response=0xdd87c8, src_addr=0xdd7a40, src_addr_len=16) at ../src/pjnath/stun_session.c:425 #9 0x00000000004d1b2b in pj_stun_client_tsx_on_rx_msg (tsx=0xdda028, msg=0xdd87c8, src_addr=0xdd7a40, src_addr_len=16) at ../src/pjnath/stun_transaction.c:437 #10 0x00000000004ced34 in on_incoming_response (sess=0xdd7f68, options=5, pkt=0xdd7148 "\001\001", pkt_len=88, msg=0xdd87c8, src_addr=0xdd7a40, src_addr_len=16) at ../src/pjnath/stun_session.c:1189 #11 0x00000000004cf3ee in pj_stun_session_on_rx_pkt (sess=0xdd7f68, packet=0xdd7148, pkt_size=88, options=1, token=0x0, parsed_len=0x0, src_addr=0xdd7a40, src_addr_len=16) at ../src/pjnath/stun_session.c:1389 #12 0x00000000004d0dbc in on_data_recvfrom (asock=0xdd7058, data=0xdd7148, size=88, src_addr=0xdd7a40, addr_len=16, status=0) at ../src/pjnath/stun_sock.c:808 #13 0x000000000054a2a3 in ioqueue_on_read_complete (key=0xdcb3b8, op_key=0xdd7918, bytes_read=88) at ../src/pj/activesock.c:482 #14 0x0000000000542fa1 in ioqueue_dispatch_read_event (ioqueue=0xdca8e0, h=0xdcb3b8) at ../src/pj/ioqueue_common_abs.c:559 #15 0x0000000000544fc0 in pj_ioqueue_poll (ioqueue=0xdca8e0, timeout=0x7f3b17673da0) at ../src/pj/ioqueue_select.c:902 #16 0x000000000045ce8a in pjsip_endpt_handle_events2 (endpt=0xdbfb48, max_timeout=0x7f3b17673de0, p_count=0x7f3b17673dfc) at ../src/pjsip/sip_endpoint.c:719 #17 0x00000000004259f8 in pjsua_handle_events (msec_timeout=10) at ../src/pjsua-lib/pjsua_core.c:1510 #18 0x0000000000423a05 in worker_thread (arg=0x0) at ../src/pjsua-lib/pjsua_core.c:568 #19 0x0000000000545ee9 in thread_main (param=0xe2c038) at ../src/pj/os_core_unix.c:494 #20 0x00007f3b1c98d971 in start_thread (arg=<value optimized out>) at pthread_create.c:304 #21 0x00007f3b1be2c92d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112 I would take a guess that PJSUA_UNLOCK() before create_sip_udp_sock() in pjsua_core.c:1791 and PJSUA_LOCK() after would suffice, but I don't know if it safe. -- Marcin Gozdalik -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20110304/6aeaa17e/attachment.html>