Index: channels/chan_local.c =================================================================== --- channels/chan_local.c (revision 213279) +++ channels/chan_local.c (working copy) @@ -600,11 +600,12 @@ ast_clear_flag(p, LOCAL_LAUNCHED_PBX); ast_module_user_remove(p->u_chan); } else { - p->owner = NULL; + /* ast should == p->owner here */ ast_module_user_remove(p->u_owner); while (p->chan && ast_channel_trylock(p->chan)) { DEADLOCK_AVOIDANCE(&p->lock); } + p->owner = NULL; /* Moved to prevent end of world in DEADLOCK_AVOIDANCE */ if (p->chan) { ast_queue_hangup(p->chan); ast_channel_unlock(p->chan);