Closed MayamaTakeshi closed 8 months ago
The problem is that we get invalid data when we try to access msg len and buf:
char evt[2048];
int sip_msg_len = 0;
char *sip_msg = (char *)"";
if (e->type == PJSIP_EVENT_TSX_STATE) {
sip_msg_len = e->body.rx_msg.rdata->msg_info.len;
sip_msg = e->body.rx_msg.rdata->msg_info.msg_buf;
}
printf("call_id=%i sip_msg_len=%i sip_msg=%p\n", call_id, sip_msg_len, sip_msg);
make_evt_call_ended(evt, sizeof(evt), call_id, sip_msg_len, sip_msg);
dispatch_event(evt);
close_media call_id=1
call_id=1 sip_msg_len=0 sip_msg=0x40000000000
Segmentation fault (core dumped)
takeshi@takeshi-desktop:sip-lab$ node samples/sip_cancel.js
close_media call_id=1
call_id=1 sip_msg_len=-1574164581 sip_msg=0x71d41ed5c3bf
Segmentation fault (core dumped)
takeshi@takeshi-desktop:sip-lab$
I tried updating to latest pjproject commit c36802585ddefb3ca477d1f6d773d179510c5412 but issue persists:
close_media call_id=1
call_id=1 sip_msg_len=1600941153 sip_msg=0x6322202c2265736e
Segmentation fault (core dumped)
takeshi@takeshi-desktop:sip-lab$
Actually our code was dying due to a bug when calling printf in event_templates.cpp:
printf("make_evt_call_ended sip_msg_len=%i sip_msg=%s\n", sip_msg_len,
sip_msg);
We will not be able to report the message body but at least there will be no crash.
This is easily reproducible with a few tries.