Fix: siprec segfault when copy delete #3632
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
To fix issue #3602.
In short, the siprec unreference the dialog recorded too early. After releasing the memory of the rtp_relay_ctx in dialog, check of the dialog (by pointer) is not valid. Do failover and end the recording(copy delete) both access the dialog (access call id, rtp relay context, etc). So, I try to unreference the dialog when the recording dialog ends.
Details
The code following will unreference the dialog when the transaction end,
opensips/modules/siprec/siprec.c
Lines 320 to 321 in b17f160
And if the recorded dialog end before the srs respond (before siprec get the b2b notify), the
srec_b2b_notify
's processing of the dialog will be uncertain. So, the segment fault is likely to raise here (when invoke rtp_relaycopy_delete
or rebuild the invite body).To simplify the code, I invoke the
src_unref_session
in thesrec_logic_destroy
function and use thekeep_sdp
flag. If this is inappropriate, please let me know.Solution
Make siprec unref the dialog when the recording end.
Compatibility
The fix works well with 3.4.11.
Closing issues