[asterisk-bugs] [Asterisk 0014705]: [patch] Deadlock when manipulating module_list over AMI and CLI

Asterisk Bug Tracker noreply at bugs.digium.com
Thu Apr 9 13:55:08 CDT 2009


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=14705 
====================================================================== 
Reported By:                jamessan
Assigned To:                tilghman
====================================================================== 
Project:                    Asterisk
Issue ID:                   14705
Category:                   Core/ManagerInterface
Reproducibility:            sometimes
Severity:                   major
Priority:                   normal
Status:                     closed
Asterisk Version:           1.4.22 
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
Resolution:                 fixed
Fixed in Version:           
====================================================================== 
Date Submitted:             2009-03-19 13:36 CDT
Last Modified:              2009-04-09 13:55 CDT
====================================================================== 
Summary:                    [patch] Deadlock when manipulating module_list over
AMI and CLI
Description: 
AMI "Action: Command" commands funnel through ast_cli_command as do actual
commands from the cli.  The difference being that when the command is
initiated from the AMI, process_message is holding the actionlock before
ast_cli_command is called.

A "module reload" command from the AMI first locks actionlock
(process_message)  and then locks the module_list (ast_module_reload).
A "module load"/"module unload" command from the CLI first locks the
module_list (ast_load_resource/ast_unload_resource) and then locks
actionlock (ast_manager_register*/ast_manager_unregister).

Therefore a properly timed "module load"/"module unload" issued from the
CLI and a "module reload" from the AMI can cause the AMI and CLI threads to
deadlock.

Releasing actionlock in process_message as soon as we find the command we
need to run is, unfortunately, not a viable solution.  If the AMI thread
were to get interrupted just after releasing the lock but before calling
the function it found, that could be removed out from under us by a CLI
command.

It would seem that blacklisting all module commands from the AMI, instead
of purely ones that would have the potential to modify the manager_action
list is the only surefire fix.
====================================================================== 

---------------------------------------------------------------------- 
 (0103038) svnbot (reporter) - 2009-04-09 13:55
 http://bugs.digium.com/view.php?id=14705#c103038 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 187487

_U  branches/1.6.2/
U   branches/1.6.2/include/asterisk/linkedlists.h
U   branches/1.6.2/include/asterisk/lock.h
U   branches/1.6.2/main/manager.c

------------------------------------------------------------------------
r187487 | tilghman | 2009-04-09 13:55:07 -0500 (Thu, 09 Apr 2009) | 22
lines

Merged revisions 187483 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r187483 | tilghman | 2009-04-09 13:40:01 -0500 (Thu, 09 Apr 2009) | 15
lines
  
  Merged revisions 187428 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r187428 | tilghman | 2009-04-09 13:08:20 -0500 (Thu, 09 Apr 2009) | 8
lines
    
    Race condition between ast_cli_command() and 'module unload' could
cause a deadlock.
    Add lock timeouts to avoid this potential deadlock.
    (closes issue http://bugs.digium.com/view.php?id=14705)
     Reported by: jamessan
     Patches: 
           20090320__bug14705.diff.txt uploaded by tilghman (license 14)
     Tested by: jamessan
  ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=187487 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-04-09 13:55 svnbot         Checkin                                      
2009-04-09 13:55 svnbot         Note Added: 0103038                          
======================================================================




More information about the asterisk-bugs mailing list