[Home]

Summary:ASTERISK-28034: chan_sip unstable with TLS after asterisk start or reloads
Reporter:David Hajek (hajekd)Labels:patch
Date Opened:2018-09-03 07:48:10Date Closed:2018-09-24 10:44:54
Priority:MajorRegression?Yes
Status:Closed/CompleteComponents:Channels/chan_sip/TCP-TLS
Versions:15.5.0 Frequency of
Occurrence
Related
Issues:
Environment:CentOS 6.9Attachments:( 0) chan_sip_tls.patch
Description:We are having issue with starting and reloading asterisk with TLS enabled phones. We have about 20 TLS enabled phones and asterisk crashes (core) or hangs in infite loop producing ERROR to full log (see error example below). The errors are generated by the for() loop in _sip_tcp_helper_thread(). I tried to track down the issue and found several issues.

* in chan_sip.c:function sip_tcptls_write(), there's missing check for tcptls_session->stream is NULL (in Asterisk 13 there was check for file descriptor isn't -1). I think this can be the reason for crashes.

* in chan_sip.c:sip_tcp_helper_thread() when read of read_pipe[0] failed I go to cleanup code and shutdown the thread. This fixes the infite loops.

Patch against 15.5.0 attached for someone more experienced with asterisk code to review. I can put it to gerrit, if required.

Yes, this patch solves the issue for us. Asterisk doesn't crash on start or reloads.

Example 1 - /var/log/asterisk/full
{noformat}
[Aug 14 10:06:27.655] ERROR[32700] chan_sip.c: read() failed: Bad file descriptor
[Aug 14 10:06:27.655] ERROR[32700] chan_sip.c: read() failed: Bad file descriptor
[Aug 14 10:06:27.655] ERROR[32700] chan_sip.c: read() failed: Bad file descriptor
[Aug 14 10:06:27.655] ERROR[32700] chan_sip.c: read() failed: Bad file descriptor
[Aug 14 10:06:27.655] ERROR[32700] chan_sip.c: read() failed: Bad file descriptor
.... infite loop
{noformat}

Example 2 - /var/log/asterisk/full
{noformat}
[Aug 30 23:13:32.337] WARNING[17387] chan_sip.c: TCPTLS thread alert_pipe indicated packet should be sent, but frame_q is empty
[Aug 30 23:13:32.337] WARNING[17387] chan_sip.c: TCPTLS thread alert_pipe indicated packet should be sent, but frame_q is empty
[Aug 30 23:13:32.337] WARNING[17387] chan_sip.c: TCPTLS thread alert_pipe indicated packet should be sent, but frame_q is empty
.... infite loop
{noformat}
Comments:By: Asterisk Team (asteriskteam) 2018-09-03 07:48:12.689-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: David Hajek (hajekd) 2018-09-03 07:49:58.376-0500

Patch against 15.5.0

By: Friendly Automation (friendly-automation) 2018-09-24 10:44:55.179-0500

Change 10206 merged by George Joseph:
chan_sip.c: chan_sip unstable with TLS after asterisk start or reloads

[https://gerrit.asterisk.org/10206|https://gerrit.asterisk.org/10206]

By: Friendly Automation (friendly-automation) 2018-09-24 10:45:34.825-0500

Change 10207 merged by George Joseph:
chan_sip.c: chan_sip unstable with TLS after asterisk start or reloads

[https://gerrit.asterisk.org/10207|https://gerrit.asterisk.org/10207]

By: Friendly Automation (friendly-automation) 2018-09-24 10:46:05.719-0500

Change 10040 merged by George Joseph:
chan_sip.c: chan_sip unstable with TLS after asterisk start or reloads

[https://gerrit.asterisk.org/10040|https://gerrit.asterisk.org/10040]