Summary: | ASTERISK-14154: [patch] Deadlock on chan_sip | ||
Reporter: | Cristian Dimache (cristiandimache) | Labels: | |
Date Opened: | 2009-05-18 00:38:48 | Date Closed: | 2009-06-08 12:42:29 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Channels/chan_sip/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) 15143.patch | |
Description: | After a random period of time (around five hours), Asterisk freezes and no calls can be made and SIP registration is unavailable. I have compiled with DEBUG_THREADS and attached the output of core show locks. At this time, killing Asterisk seems to be the only way to solve the problem. I use realtime peers, but I don't think this is an issue here. ****** ADDITIONAL INFORMATION ****** voip0*CLI> core show locks voip0*CLI> ======================================================================= === Currently Held Locks ============================================== ======================================================================= === === <pending> <lock#> (<file>): <lock type> <line num> <function> <lock name> <lock addr> (times locked) === === Thread ID: -1295414384 (do_monitor started at [20435] chan_sip.c restart_monitor()) === ---> Lock #0 (chan_sip.c): MUTEX 19947 handle_request_do &netlock 0xb2d37260 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/lib/asterisk/modules/chan_sip.so [0xb2d1f5ff] /usr/lib/asterisk/modules/chan_sip.so [0xb2d22bae] /usr/sbin/asterisk(ast_io_wait+0xc1) [0x8122091] /usr/lib/asterisk/modules/chan_sip.so [0xb2d179ce] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === ---> Lock #1 (chan_sip.c): MUTEX 6464 find_call sip_pvt_ptr 0x83e9ba8 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/sbin/asterisk(_ao2_lock+0x31b) [0x808452b] /usr/lib/asterisk/modules/chan_sip.so [0xb2ccf334] /usr/lib/asterisk/modules/chan_sip.so [0xb2d1ed27] /usr/lib/asterisk/modules/chan_sip.so [0xb2d22bae] /usr/sbin/asterisk(ast_io_wait+0xc1) [0x8122091] /usr/lib/asterisk/modules/chan_sip.so [0xb2d179ce] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === ---> Lock #2 (chan_sip.c): MUTEX 19961 handle_request_do (channel lock) 0x8609ea0 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/sbin/asterisk(__ast_channel_trylock+0x343) [0x80a3153] /usr/lib/asterisk/modules/chan_sip.so [0xb2d1eddb] /usr/lib/asterisk/modules/chan_sip.so [0xb2d22bae] /usr/sbin/asterisk(ast_io_wait+0xc1) [0x8122091] /usr/lib/asterisk/modules/chan_sip.so [0xb2d179ce] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === ---> Waiting for Lock #3 (pbx.c): MUTEX 8366 pbx_builtin_setvar_helper (channel lock) 0xb6a28270 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/sbin/asterisk(__ast_channel_lock+0x44b) [0x80a371b] /usr/sbin/asterisk(pbx_builtin_setvar_helper+0x52) [0x8155cf2] /usr/sbin/asterisk(ast_rtp_set_vars+0x10e) [0x81708ce] /usr/lib/asterisk/modules/chan_sip.so [0xb2ccfdf3] /usr/lib/asterisk/modules/chan_sip.so [0xb2d1cf39] /usr/lib/asterisk/modules/chan_sip.so [0xb2d1f204] /usr/lib/asterisk/modules/chan_sip.so [0xb2d22bae] /usr/sbin/asterisk(ast_io_wait+0xc1) [0x8122091] /usr/lib/asterisk/modules/chan_sip.so [0xb2d179ce] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === --- ---> Locked Here: channel.c line 4056 (ast_do_masquerade) === ------------------------------------------------------------------- === === Thread ID: -1300915312 (pbx_thread started at [ 4045] pbx.c ast_pbx_start()) === ---> Waiting for Lock #0 (channel.c): MUTEX 1953 ast_waitfor_nandfds (channel lock) 0x8609ea0 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/sbin/asterisk(__ast_channel_lock+0x44b) [0x80a371b] /usr/sbin/asterisk(ast_waitfor_nandfds+0x9a) [0x80aea2a] /usr/sbin/asterisk(ast_channel_bridge+0x7a2) [0x80b0082] /usr/sbin/asterisk(ast_bridge_call+0x3bf) [0x80f5a2f] /usr/lib/asterisk/modules/app_queue.so [0xb640d295] /usr/lib/asterisk/modules/app_queue.so [0xb641df4f] /usr/sbin/asterisk(pbx_exec+0x84) [0x8153fa4] /usr/lib/asterisk/modules/pbx_realtime.so [0xb6647469] /usr/sbin/asterisk [0x815d025] /usr/sbin/asterisk [0x815e34d] /usr/sbin/asterisk [0x8162328] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === --- ---> Locked Here: chan_sip.c line 19961 (handle_request_do) === ------------------------------------------------------------------- === === Thread ID: -1299686512 (pbx_thread started at [ 4045] pbx.c ast_pbx_start()) === ---> Lock #0 (channel.c): MUTEX 2509 __ast_read (channel lock) 0xb6acbd98 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/sbin/asterisk(__ast_channel_trylock+0x343) [0x80a3153] /usr/sbin/asterisk [0x80ad034] /usr/sbin/asterisk(ast_channel_bridge+0x7b7) [0x80b0097] /usr/sbin/asterisk(ast_bridge_call+0x3bf) [0x80f5a2f] /usr/lib/asterisk/modules/app_dial.so [0xb2dee277] /usr/lib/asterisk/modules/app_dial.so [0xb2df04bd] /usr/sbin/asterisk(pbx_exec+0x84) [0x8153fa4] /usr/lib/asterisk/modules/pbx_realtime.so [0xb6647469] /usr/sbin/asterisk [0x815d025] /usr/sbin/asterisk [0x815e34d] /usr/sbin/asterisk [0x8162328] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === ---> Lock #1 (channel.c): MUTEX 4056 ast_do_masquerade (channel lock) 0xb6a28270 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/sbin/asterisk(__ast_channel_lock+0x44b) [0x80a371b] /usr/sbin/asterisk(ast_indicate_data+0x2c) [0x80a7f5c] /usr/sbin/asterisk(ast_channel_bridge+0xa1e) [0x80b02fe] /usr/sbin/asterisk(ast_bridge_call+0x3bf) [0x80f5a2f] /usr/lib/asterisk/modules/app_queue.so [0xb640d295] /usr/lib/asterisk/modules/app_queue.so [0xb641df4f] /usr/sbin/asterisk(pbx_exec+0x84) [0x8153fa4] /usr/lib/asterisk/modules/pbx_realtime.so [0xb6647469] /usr/sbin/asterisk [0x815d025] /usr/sbin/asterisk [0x815e34d] /usr/sbin/asterisk [0x8162328] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === ---> Lock #2 (chan_sip.c): MUTEX 5174 sip_hangup p 0xb6ac6be8 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/sbin/asterisk(_ao2_lock+0x31b) [0x808452b] /usr/lib/asterisk/modules/chan_sip.so [0xb2d0273b] /usr/sbin/asterisk(ast_do_masquerade+0x556) [0x80ab066] /usr/sbin/asterisk [0x80ad298] /usr/sbin/asterisk(ast_channel_bridge+0x7b7) [0x80b0097] /usr/sbin/asterisk(ast_bridge_call+0x3bf) [0x80f5a2f] /usr/lib/asterisk/modules/app_dial.so [0xb2dee277] /usr/lib/asterisk/modules/app_dial.so [0xb2df04bd] /usr/sbin/asterisk(pbx_exec+0x84) [0x8153fa4] /usr/lib/asterisk/modules/pbx_realtime.so [0xb6647469] /usr/sbin/asterisk [0x815d025] /usr/sbin/asterisk [0x815e34d] /usr/sbin/asterisk [0x8162328] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === ---> Waiting for Lock #3 (pbx.c): MUTEX 8366 pbx_builtin_setvar_helper (channel lock) 0x8609ea0 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/sbin/asterisk(__ast_channel_lock+0x44b) [0x80a371b] /usr/sbin/asterisk(pbx_builtin_setvar_helper+0x52) [0x8155cf2] /usr/sbin/asterisk(ast_rtp_set_vars+0x10e) [0x81708ce] /usr/lib/asterisk/modules/chan_sip.so [0xb2d03052] /usr/sbin/asterisk(ast_do_masquerade+0x556) [0x80ab066] /usr/sbin/asterisk [0x80ad298] /usr/sbin/asterisk(ast_channel_bridge+0x7b7) [0x80b0097] /usr/sbin/asterisk(ast_bridge_call+0x3bf) [0x80f5a2f] /usr/lib/asterisk/modules/app_dial.so [0xb2dee277] /usr/lib/asterisk/modules/app_dial.so [0xb2df04bd] /usr/sbin/asterisk(pbx_exec+0x84) [0x8153fa4] /usr/lib/asterisk/modules/pbx_realtime.so [0xb6647469] /usr/sbin/asterisk [0x815d025] /usr/sbin/asterisk [0x815e34d] /usr/sbin/asterisk [0x8162328] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === --- ---> Locked Here: chan_sip.c line 19961 (handle_request_do) === ------------------------------------------------------------------- === === Thread ID: -1300178032 (pbx_thread started at [ 4045] pbx.c ast_pbx_start()) === ---> Lock #0 (channel.c): MUTEX 2509 __ast_read (channel lock) 0xb6ac4de8 (1) /usr/sbin/asterisk(ast_bt_get_addresses+0x1a) [0x812d6fa] /usr/sbin/asterisk(__ast_channel_trylock+0x343) [0x80a3153] /usr/sbin/asterisk [0x80ad034] /usr/lib/asterisk/modules/app_dial.so [0xb2de962f] /usr/lib/asterisk/modules/app_dial.so [0xb2ded9c2] /usr/lib/asterisk/modules/app_dial.so [0xb2df04bd] /usr/sbin/asterisk(pbx_exec+0x84) [0x8153fa4] /usr/lib/asterisk/modules/pbx_realtime.so [0xb6647469] /usr/sbin/asterisk [0x815d025] /usr/sbin/asterisk [0x815e34d] /usr/sbin/asterisk [0x8162328] /usr/sbin/asterisk [0x81bdaaa] /lib/i686/cmov/libpthread.so.0 [0xb7e5c4e5] /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === ------------------------------------------------------------------- === ======================================================================= | ||
Comments: | By: Gregory Hinton Nietsky (irroot) 2009-05-19 13:05:34 Ok this may be related to ASTERISK-14162 i belive so due to the following ... not the most detailed argument for assosiation but i belive a strong one. the version here is 1.6 and the orig bug i posted is 1.4 so square peg into round hole time .... ###### The patch allows chan->masq to be pased before checking the FD == Thread ID: -1300178032 (pbx_thread started at [ 4045] pbx.c ast_pbx_start()) === ---> Lock #0 (channel.c): MUTEX 2509 __ast_read (channel lock) 0xb6ac4de8 (1) ##### See above the lock is while masqurading === ---> Lock #1 (channel.c): MUTEX 4056 ast_do_masquerade (channel lock) 0xb6a28270 (1) ##### The lock is generated when the find private returns the struct locked as per me patch .... === ---> Lock #1 (chan_sip.c): MUTEX 6464 find_call sip_pvt_ptr 0x83e9ba8 (1) /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb707610e] === ---> Lock #2 (chan_sip.c): MUTEX 19961 handle_request_do (channel lock) 0x8609ea0 (1) By: Cristian Dimache (cristiandimache) 2009-05-29 10:13:55 I've patched my 1.6.1 with something in the lines of the last patch from ASTERISK-1497151, let's see how it goes. By: Cristian Dimache (cristiandimache) 2009-05-30 01:19:30 I've changed chan_sip.c from my 1.6.x around the lines in the patch for 1.4. Still deadlock, but it could be a bad patch on my part. I am not sure that a transfer is responsible for this. Is there any way for me to replicate a onelegged transfer so I can test if this is the cause? By: Mark Michelson (mmichelson) 2009-06-04 13:28:29 I've uploaded 15143.patch to this issue. Please try applying that and see if the deadlock still occurs. Thanks! By: Cristian Dimache (cristiandimache) 2009-06-08 05:24:10 I've patched Asterisk with 15143.patch. I will confirm that the patch works after a couple of days of use. By: Digium Subversion (svnbot) 2009-06-08 12:32:05 Repository: asterisk Revision: 199588 U trunk/channels/chan_sip.c ------------------------------------------------------------------------ r199588 | mmichelson | 2009-06-08 12:32:05 -0500 (Mon, 08 Jun 2009) | 9 lines Fix a deadlock that could occur when setting rtp stats on SIP calls. (closes issue ASTERISK-14154) Reported by: cristiandimache Patches: 15143.patch uploaded by mmichelson (license 60) Tested by: cristiandimache ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=199588 By: Digium Subversion (svnbot) 2009-06-08 12:33:17 Repository: asterisk Revision: 199589 _U branches/1.6.0/ ------------------------------------------------------------------------ r199589 | mmichelson | 2009-06-08 12:33:17 -0500 (Mon, 08 Jun 2009) | 14 lines Blocked revisions 199588 via svnmerge ........ r199588 | mmichelson | 2009-06-08 12:32:04 -0500 (Mon, 08 Jun 2009) | 9 lines Fix a deadlock that could occur when setting rtp stats on SIP calls. (closes issue ASTERISK-14154) Reported by: cristiandimache Patches: 15143.patch uploaded by mmichelson (license 60) Tested by: cristiandimache ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=199589 By: Digium Subversion (svnbot) 2009-06-08 12:35:59 Repository: asterisk Revision: 199590 _U branches/1.6.1/ U branches/1.6.1/channels/chan_sip.c ------------------------------------------------------------------------ r199590 | mmichelson | 2009-06-08 12:35:58 -0500 (Mon, 08 Jun 2009) | 15 lines Recorded merge of revisions 199588 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r199588 | mmichelson | 2009-06-08 12:32:04 -0500 (Mon, 08 Jun 2009) | 9 lines Fix a deadlock that could occur when setting rtp stats on SIP calls. (closes issue ASTERISK-14154) Reported by: cristiandimache Patches: 15143.patch uploaded by mmichelson (license 60) Tested by: cristiandimache ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=199590 By: Digium Subversion (svnbot) 2009-06-08 12:42:28 Repository: asterisk Revision: 199591 _U branches/1.6.2/ U branches/1.6.2/channels/chan_sip.c ------------------------------------------------------------------------ r199591 | mmichelson | 2009-06-08 12:42:28 -0500 (Mon, 08 Jun 2009) | 15 lines Recorded merge of revisions 199588 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r199588 | mmichelson | 2009-06-08 12:32:04 -0500 (Mon, 08 Jun 2009) | 9 lines Fix a deadlock that could occur when setting rtp stats on SIP calls. (closes issue ASTERISK-14154) Reported by: cristiandimache Patches: 15143.patch uploaded by mmichelson (license 60) Tested by: cristiandimache ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=199591 |