[asterisk-bugs] [Asterisk 0018310]: [patch] hint state changes deadlock/race

Asterisk Bug Tracker noreply at bugs.digium.com
Wed Jan 5 16:37:17 UTC 2011


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=18310 
====================================================================== 
Reported By:                one47
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   18310
Category:                   Core/PBX
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     ready for testing
Asterisk Version:           1.6.2.14 
JIRA:                       SWP-2541 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2010-11-15 12:19 CST
Last Modified:              2011-01-05 10:37 CST
====================================================================== 
Summary:                    [patch] hint state changes deadlock/race
Description: 
VERY similar to https://issues.asterisk.org/view.php?id=18165, but this is a
different deadlock path, so I have
raised a separate report.

Thread 1: taskprocessor  -> handle_statechange
    Lock order = conlock, hints, hint, pvt
Thread 2: chan_sip.c:  handle_request_do -> handle_response_notify
    Lock order = pvt, conlock

Thread2 only gets into the conlock if STATECHANGEQUEUE is true, ie. there
are rapid state changes happening on a subscribed hint.
======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
related to          0018165 [patch] hint state changes deadlock pro...
has duplicate       0018535 app_queue deadlocks if weight is set
====================================================================== 

---------------------------------------------------------------------- 
 (0130208) one47 (reporter) - 2011-01-05 10:37
 https://issues.asterisk.org/view.php?id=18310#c130208 
---------------------------------------------------------------------- 
It seems that this patch is okay, but that it does not go far enough...

1) Performance - This patch is no worse performance wise that the
unpatched code - The deadlock avoidance is called so rarely that it will
have an effect tending towards zero.

2) Additional issue. In chan_sip.c:cb_extensionstate(), there is a
potential call to chan_sip.c:transmit_state_notify()

Within transmit_state_notify(), if "notifycid" is enabled, then there is a
call into channel.c:ast_channel_search_locked(), which is a deadlock
waiting to happen, particularly if called with 4 other locks held as in
this case.

ast_channel_search_locked() has no deadlock avoidance code, so things lock
hard.

The only way I have found to cause the above to be a problem is to drop
call-files which generate a Local/ channel - The nature of the Local/
channel means that it grabs a channel lock, and then shortly afterwards
needs the context-lock - This is the reverse of what handle_statechange
does, so deadlocks...

3) Way forward - Did anyone (stefan?) manage to patch handle_statechange()
so that it no longer needs the context-lock? That certainly looks like a
promising way forward. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-01-05 10:37 one47          Note Added: 0130208                          
======================================================================




More information about the asterisk-bugs mailing list