Opened 7 years ago
Closed 7 years ago
#2117 closed defect (fixed)
Crash when deleting PJSUA2 Account
Reported by: | nanang | Owned by: | bennylp |
---|---|---|---|
Priority: | normal | Milestone: | release-2.8 |
Component: | pjsua2 | Version: | trunk |
Keywords: | Cc: | ||
Backport to 1.x milestone: | Backported: | no |
Description
Scenario:
- Thread 1 deletes SipAccount instance, which derived from PJSUA2 Account. In SipAccount destructor, some SipAccount member objects have been destroyed.
- Thread 2 invokes Account callback onRegState() (e.g: from registration refresh), it tries to access SipAccount member objects, as some of them have been destroyed, crash occurs.
Some related facts:
- Account destructor and onRegState() callback are mutual exclusive, because in PJSUA level, they are protected with PJSUA lock. But SipAccount destructor and onRegState() callback are not mutual exclusive.
- Once pjsua_acc_del() in Account destructor is executed, onRegState() should never be invoked (for unregistration completion). Unfortunately, in derived class destruction, parent/Account destructor is called last.
The proposed solution is to introduce new Account method, i.e: Account::shutdown(), that internally will invoke PJSUA pjsua_acc_del(), so derived class could call this method first in its destructor to avoid invocation of onRegState() when it is being destroyed. Or alternatively, application can manually call Account::shutdown() before deleting the derived class instance.
Thanks Thomas Hackl for the report.
Change History (1)
comment:1 Changed 7 years ago by nanang
- Resolution set to fixed
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.
In 5801: