Summary:ASTERISK-17607: [patch] Conversion of hints to AO2 may changes locking order
Reporter:Steve Davies (one47)Labels:
Date Opened:2011-03-25 05:06:26Date Closed:2011-11-21 14:25:53.000-0600
Versions: Frequency of
Environment:Attachments:( 0) hint.lock.patch
Description:Potential deadlock due to locking order change.

BEFORE the AO2 conversion, pbx.c would always grab the conlock before grabbing the hints lock.

SINCE the conversion, the conlock is not grabbed directly at-all, and the hints lock it the top-level lock for handling state change notifications.

Incidentally, while sending notifications, the conlock is grabbed to be able to read the "hint" values from the dialplan. This gives an implied locking order of hints and then conlock.

pbx.c currently says that the opposite is true.


Comment from pbx.c at present, which I believe to be incorrect:

 When holding this container's lock, do _not_ do anything that will cause conlock
 to be taken, unless you _already_ hold it. The ast_merge_contexts_and_delete
 function will take the locks in conlock/hints order, so any other
 paths that require both locks must also take them in that order.
static struct ao2_container *hints;

Comments:By: Steve Davies (one47) 2011-03-25 05:06:51

Potential patch attached.

By: David Vossel (dvossel) 2011-07-20 11:38:20.799-0500

when this patch is committed, it will likely resolve this issue.  At least for 1.8 and up. https://reviewboard.asterisk.org/r/1313/

By: Matt Jordan (mjordan) 2011-11-21 14:25:20.285-0600

Per the Asterisk maintenance timeline page at http://www.asterisk.org/asterisk-versions maintenance (bug) support for the 1.4 and 1.6.x branches has ended. For continued maintenance support please move to the 1.8 branch which is a long term support (LTS) branch. For more information about branch support, please see https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions.  After testing with Asterisk 1.8, if you find this problem has not been resolved, please open a new issue against Asterisk 1.8.