<div dir="ltr">Hello Asterisk users and developers,<div>The last few weeks we had several crashes on live asterisks running versions  12.2.0rc1 / 12.6.1 with PJPROJECT versions 2.1.0 / 2.2.1. We opened a ticket - ASTERISK-24471.</div><div><br></div><div>After investigating the issue I can say that the scenario is a CANCEL being received while handling ANSWER and before generating the 200OK response.</div><div><br></div><div>Looking at the core file we see that the problem is in - pjsip/src/pjsip/sip_transaction.c line 3158 :</div><div><div>        PJ_ASSERT_RETURN(event->type == PJSIP_EVENT_TX_MSG &&</div><div>                         <span style="background-color:rgb(255,255,0)">event->body.tx_msg.tdata == tsx->last_tx</span>,</div><div>                         PJ_EINVALIDOP);</div></div><div><br></div><div>After investigating further I came to a conclusion that the second expression fails (marked with yellow), and that causes the Asterisk to crash. </div><div><br></div><div>I have already removed the expression and logged whenever this expression fails. It seems to work fine. Since the change it the happened several times, the application didn't crash and going over the debug it seems that the call was handled fine.</div><div><br></div><div>Can anyone tell what is the purpose of this expression? Any explanation why this expression fails in the above scenario?</div><div><br></div><div>Thanks,</div><div>Yaron.</div></div>