<p style="white-space: pre-wrap; word-wrap: break-word;">Sorry I don't have time to do a complete review but I think you need to add `ast_module_shutdown_ref` at the end of load_module right before it returns success.  This bug shows that something has callbacks into res_pjsip_mwi without holding a module reference so CLI `module unload res_pjsip_mwi` could cause a crash.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/12998">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/12998">change 12998</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/12998"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: I8f812286dc19a34916acacd71ce2ec26e1042047 </div>
<div style="display:none"> Gerrit-Change-Number: 12998 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-CC: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Wed, 02 Oct 2019 16:32:49 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>