Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion due to deleted account during incoming call in PJSUA2 #4024

Merged
merged 2 commits into from
Jul 29, 2024

Conversation

nanangizz
Copy link
Member

Reported that assertion occurs in incoming call callback due to the selected account is being deleted:

../src/pjsua-lib/pjsua_acc.c:650: void *pjsua_acc_get_user_data(pjsua_acc_id): assertion "pjsua_var.acc[acc_id].valid" failed

pjsua_acc_get_user_data+280
pj::Account::lookup(int)+20
pj::Endpoint::lookupAcc(int, char const*)+24
pj::Endpoint::on_incoming_call(int, int, pjsip_rx_data*)+60)
pjsua_call_on_incoming+6336

Initially this sounds strange as pjsua_call_on_incoming() and pjsua_acc_del() seem to be mutually exclusive, i.e: protected by PJSUA lock. However, after investigation, it is possible because pjsua_call_on_state_changed() may temporarily release the PJSUA lock. In PJSUA2 (not the case in PJSUA), the pjsua_call_on_state_changed() will be called when a 100/Trying response is sent and the incoming call callback is called early (before media transport creation callback and before sending 100 response).

The assertion seems to occur when PJSUA invokes incoming call callback (after sending 100 response or pjsua_call_on_state_changed()) which eventually will be ignored by PJSUA2 as such callback has been called earlier, so the proposed solution here is to avoid invoking the PJSUA callback when PJSUA2 has invoke the incoming call callback earlier.

Thanks to Valery Kolesnikov for the report.

@nanangizz nanangizz added this to the release-2.15 milestone Jul 26, 2024
/* For PJSUA2, avoid invoking this callback again when it has been
* invoked from on_media_transport_created().
*/
if (call->incoming_data) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it impact somehow on pjsua interface callbacks?

Copy link
Member Author

@nanangizz nanangizz Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not. The call->incoming_data is only released & set to NULL after invoking incoming call callback.

@@ -2167,7 +2167,12 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
* otherwise hangup the call with 480
*/
if (pjsua_var.ua_cfg.cb.on_incoming_call) {
pjsua_var.ua_cfg.cb.on_incoming_call(acc_id, call_id, rdata);
/* For PJSUA2, avoid invoking this callback again when it has been
* invoked from on_media_transport_created().
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanangizz nanangizz merged commit 0e0573d into master Jul 29, 2024
36 checks passed
@nanangizz nanangizz deleted the pjsua2-race-incoming-call-del-acc branch July 29, 2024 06:48
vkolesnikov-intermedia pushed a commit to vkolesnikov-intermedia/pjproject that referenced this pull request Jul 29, 2024
vkolesnikov-intermedia pushed a commit to intermedia-net/pjproject that referenced this pull request Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants