<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/5870">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Core/PBX: Deadlock between dialplan execution and application unregistration.<br><br>Not easy to reproduce, but we have noticed deadlocks when unloading a module<br>while dialplan is handling a request.<br><br>The deadlock is between :<br>1) Dialplan execution: pbx_extension_helper() first taking conlock,<br>then pbx_findapp() [when called] asking for lock on apps list.<br>2) Application unregistration: ast_unregister_application() first taking lock<br>on apps list, then unreference_cached_app() [when called] asking for conlock.<br><br>As a protection, I suggest to modify ast_unregister_application(), so that it<br>anticipates the need of conlock, before taking the lock on apps list.<br>The side effect is a longer unavailability of conlock when unregistering an<br>application.<br><br>ASTERISK-27041<br><br>Change-Id: I0db0f1eb320da6a5758cce3a47d765be1face8e2<br>---<br>M main/pbx_app.c<br>1 file changed, 7 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/70/5870/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/pbx_app.c b/main/pbx_app.c<br>index e0609db..ec6bc75 100644<br>--- a/main/pbx_app.c<br>+++ b/main/pbx_app.c<br>@@ -394,6 +394,11 @@<br> struct ast_app *cur;<br> int cmp;<br> <br>+ /* Anticipate need for conlock in unreference_cached_app(), in order to avoid<br>+ * possible deadlock with pbx_extension_helper()/pbx_findapp()<br>+ */<br>+ ast_rdlock_contexts();<br>+<br> AST_RWLIST_WRLOCK(&apps);<br> AST_RWLIST_TRAVERSE_SAFE_BEGIN(&apps, cur, list) {<br> cmp = strcasecmp(app, cur->name);<br>@@ -416,6 +421,8 @@<br> AST_RWLIST_TRAVERSE_SAFE_END;<br> AST_RWLIST_UNLOCK(&apps);<br> <br>+ ast_unlock_contexts();<br>+<br> return cur ? 0 : -1;<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/5870">change 5870</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/5870"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I0db0f1eb320da6a5758cce3a47d765be1face8e2 </div>
<div style="display:none"> Gerrit-Change-Number: 5870 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Frederic LE FOLL <frederic.lefoll@c-s.fr> </div>