[Asterisk-code-review] pjproject: fixed a few bugs (asterisk[13])

Alexei Gradinari asteriskteam at digium.com
Wed Jul 20 12:54:47 CDT 2016


Alexei Gradinari has posted comments on this change.

Change subject: pjproject: fixed a few bugs
......................................................................


Patch Set 3:

(1 comment)

https://gerrit.asterisk.org/#/c/3254/3/third-party/pjproject/patches/0001-pjproject-pjsip_tx_data_dec_ref.patch
File third-party/pjproject/patches/0001-pjproject-pjsip_tx_data_dec_ref.patch:

PS3, Line 9: +    if (!atomic_var) {
           : +	return -1;
           : +    }
> Is this actually band-aiding another issue? (For example this comes up if a
It happens when dialog has been already destroyed.

The asterisk under heavy load could call pjsip_tx_data_dec_ref twice from different threads at the same time.
In both threads pj_atomic_get(tdata->ref_cnt) > 0 is true when it's executed.
and both threads call pj_atomic_dec_and_get(tdata->ref_cnt)
There are 2 cases:

The one of the threads decreased ref_cnt and destroyed dialog.
In this case another thread got SEGV when attempting to lock mutex.

The one of the threads decreased ref_cnt, but hadn't destroyed dialog yet.
In this case another thread decreased the counter, but because the counter was 0
it returned -1 and pjsip_tx_data_dec_ref attempted to destroy already destroyed dialog.

This patch fixed both cases.

May be we should also replace
pj_assert( pj_atomic_get(tdata->ref_cnt) > 0);
to
if (pj_atomic_get(tdata->ref_cnt) <= 0) return PJ_SUCCESS;


-- 
To view, visit https://gerrit.asterisk.org/3254
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8b05917c93d993f95d604c042ace5f1a5500f59a
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-HasComments: Yes



More information about the asterisk-code-review mailing list