<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,<br>
    </p>
    <div class="moz-cite-prefix">On 02.06.21 19:00, Trevor Hemsley
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:eda8d604-1d66-66a8-379d-8aa19888e448@voiceflex.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <style type="text/css">.style1 {font-family: "Times New Roman";}</style>
      <div class="moz-text-html" lang="x-western"> Hi<br>
        <br>
        We've seen a few occurrences of this crash since we implemented
        kamailio 5.4.5 for our inbound call traffic.</div>
    </blockquote>
    <p>to clarify: have you made an update to kamailio 5.4.5 from an
      older version and since then you started to have such crashes? If
      yes, what was the previous version? I quickly checked and there
      were no major changes to dialog module in 5.4 branch.<br>
    </p>
    <p>If you started with this version, is it under heavy load? Have
      you captured the SIP traffic? It would be useful to see the sip
      messages for such call. <br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:eda8d604-1d66-66a8-379d-8aa19888e448@voiceflex.com">
      <div class="moz-text-html" lang="x-western"> Preceding the crash
        we always get a message in the logs about "dialog
        [dlg_hash.c:1182]: next_state_dlg(): bogus event 2 in state 5
        for dlg" and whenever we see that message, we get the crash.<br>
        <br>
        JunĀ  1 10:12:14 thissystem /usr/sbin/kamailio[20001]: CRITICAL:
        {2 1 INVITE <a class="moz-txt-link-abbreviated"
          href="mailto:6787142-3831531134-1330894187@some.telco.domain"
          moz-do-not-send="true">
          6787142-3831531134-1330894187@some.telco.domain</a>} dialog
        [dlg_hash.c:1182]: next_state_dlg(): bogus event 2 in state 5
        for dlg 0x7fae153d3cf0 [3973:6059] with clid '<a
          class="moz-txt-link-abbreviated"
          href="mailto:82608924-3831089984-1833452161@some.telco.domain"
          moz-do-not-send="true">82608924-3831089984-1833452161@some.telco.domain</a>'
        and tags '3831089984-684203260' ''<br>
        <br>
        The crash happens on line 879 of <a
          class="moz-txt-link-freetext"
href="https://github.com/kamailio/kamailio/blob/master/src/modules/dialog/dlg_db_handler.c"
          target="_BLANK" moz-do-not-send="true">
https://github.com/kamailio/kamailio/blob/master/src/modules/dialog/dlg_db_handler.c</a></div>
    </blockquote>
    <p>You reference to code in master branch, not in 5.4 branch, so
      unless you did the remapping, the lines might not be the same. <br>
    </p>
    <p>If you have the core dump files, the best is to get the output of
      the next gdb commands:</p>
    <p>"""<br>
      bt full</p>
    <p>list</p>
    <p>info locals<br>
      ""<br>
    </p>
    <p>You can eventually open an issue in the bug tracker to collect
      the details there and assist with troubleshooting.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:eda8d604-1d66-66a8-379d-8aa19888e448@voiceflex.com">
      <div class="moz-text-html" lang="x-western"> <br>
        <br>
        <pre><span class="pl-c1">SET_STR_VALUE</span>(values+<span class="pl-c1">7</span>, cell-><span class="pl-smi">bind_addr</span>[DLG_CALLER_LEG]-><span class="pl-smi">sock_str</span>);</pre>
        <br>
        Looking at gdb, I see that cell-><span class="pl-smi">bind_addr</span>[DLG_CALLER_LEG]
        == 0 so trying to use it results in the segfault. I have thought
        about patching that to check for bind_addr being set and
        bypassing that line if not but I do not think it's the right fix
        though it probably would avoid the current crash (and do odd
        things later instead!). I did check that everything else in that
        function that uses DLG_CALLER_LEG is set correctly and it
        appears that it is - or at least if not correctly then they are
        at least set!<br>
        <br>
        The "bogus event 2 in state 5" message is coming out from line
        1143 in src/modules/ims_dialog/dlg_hash.c<br>
        <br>
        <pre>        case DLG_EVENT_RPL1xx:
            switch (dlg->state) {
                case DLG_STATE_UNCONFIRMED:
                case DLG_STATE_EARLY:
                    dlg->state = DLG_STATE_EARLY;
                    break;
                default:
                    log_next_state_dlg(event, dlg);
            }
            break;

</pre>
        (I didn't really understand why it would set dlg->state =
        DLG_STATE_EARLY if it's already DLG_STATE_EARLY but...)<br>
        <br>
        I have a couple of core dumps of this from the last day or two -
        usually seems to crash at least once a week on our pair of
        kamailio inbound servers. If there's any more info I can provide
        to help fix this properly rather than my proposed bodge then
        feel free to ask.<br>
        <br>
        Trevor Hemsley<br>
      </div>
      <br>
      <br>
      <p style="font-family: Verdana; font-size:10pt; color:#666666;"><b>Disclaimer</b></p>
      <p style="font-family: Verdana; font-size:8pt; color:#666666;">The
        information contained in this communication from the sender is
        confidential. It is intended solely for use by the recipient and
        others authorized to receive it. If you are not the recipient,
        you are hereby notified that any disclosure, copying,
        distribution or taking action in relation of the contents of
        this information is strictly prohibited and may be unlawful.<br>
        <br>
        This email has been scanned for viruses and malware, and may
        have been automatically archived by <b>Mimecast Ltd</b>, an
        innovator in Software as a Service (SaaS) for business.
        Providing a <b>safer</b> and <b>more useful</b> place for your
        human generated data. Specializing in; Security, archiving and
        compliance. To find out more <a
          href="http://www.mimecast.com/products/" target="_blank"
          moz-do-not-send="true">Click Here</a>.</p>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * <a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Online - June 7-10, 2021 (America Timezone)
  * <a class="moz-txt-link-freetext" href="https://www.asipto.com/sw/kamailio-advanced-training-online/">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
  </body>
</html>