Summary:ASTERISK-27534: chan_sip: Assumes iostream is non-NULL when it may not be
Reporter:Lubos Dolezel (LubosD)Labels:patch
Date Opened:2017-12-26 12:19:00.000-0600Date Closed:2018-01-12 08:46:21.000-0600
Status:Closed/CompleteComponents:Channels/chan_sip/General Core/General
Versions:15.1.4 Frequency of
Environment:Attachments:( 0) ASTERISK-27534.diff
Description:I'd like to report a crash, this is the backtrace based on the coredump:

#0  ast_iostream_get_fd (stream=0x0) at iostream.c:75
#1  0x00007f32d32355d4 in sip_prepare_socket (p=0x7f325c057598) at chan_sip.c:29239
#2  __sip_xmit (p=0x7f325c057598, data=0x7f325c010210) at chan_sip.c:3753
#3  0x00007f32d323600d in __sip_reliable_xmit (p=p@entry=0x7f325c057598, seqno=seqno@entry=102, resp=resp@entry=0, data=<optimized out>, fatal=fatal@entry=1, sipmethod=<optimized out>) at chan_sip.c:4267
#4  0x00007f32d323c1c9 in send_request (p=0x7f325c057598, req=0x7f32ba8be040, reliable=XMIT_CRITICAL, seqno=102) at chan_sip.c:4816
#5  0x00007f32d3255220 in transmit_invite (p=p@entry=0x7f325c057598, sipmethod=sipmethod@entry=3, sdp=sdp@entry=0, init=init@entry=2, explicit_uri=explicit_uri@entry=0x0) at chan_sip.c:14801
#6  0x00007f32d325eb98 in sip_poke_peer (peer=peer@entry=0x2e8ff58, force=force@entry=0) at chan_sip.c:30300
#7  0x00007f32d325f295 in sip_poke_peer_s (data=0x2e8ff58) at chan_sip.c:16587
#8  0x00000000005cff9f in ast_sched_runq (con=0x2e5da40) at sched.c:781
#9  0x00007f32d3278e75 in do_monitor (data=data@entry=0x0) at chan_sip.c:29709
#10 0x00000000006186dd in dummy_start (data=<optimized out>) at utils.c:1257
#11 0x00007f338f70e73a in start_thread () from /lib64/libpthread.so.0
#12 0x00007f338ebef85f in clone () from /lib64/libc.so.6

Asterisk would crash every ~1 hour or so. At this point, it is sending out an OPTIONS packet to a {{host=dynamic}} SIP peer that has {{qualify}} enabled and frequently goes offline. The peer uses TLS.

(gdb) f 1
#1  0x00007f32d32355d4 in sip_prepare_socket (p=0x7f325c057598) at chan_sip.c:29239
29239                   return ast_iostream_get_fd(s->tcptls_session->stream);
(gdb) p s->tcptls_session
$3 = (struct ast_tcptls_session_instance *) 0x7f3268000b98
(gdb) p s->tcptls_session->stream
$4 = (struct ast_iostream *) 0x0

Turning {{qualify}} off for this peer fixed the problem.
Comments:By: Asterisk Team (asteriskteam) 2017-12-26 12:19:01.720-0600

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: Joshua C. Colp (jcolp) 2017-12-27 18:44:18.558-0600

Please try this attached patch. It can be applied to Asterisk 15 using:

patch -p1 < ASTERISK-27534.diff

By: Asterisk Team (asteriskteam) 2018-01-11 12:00:01.622-0600

Suspended due to lack of activity. This issue will be automatically re-opened if the reporter posts a comment. If you are not the reporter and would like this re-opened please create a new issue instead. If the new issue is related to this one a link will be created during the triage process. Further information on issue tracker usage can be found in the Asterisk Issue Guidlines [1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines

By: Corey Farrell (coreyfarrell) 2018-01-11 12:34:20.461-0600

Removing the 'regression' flag since this bug was introduced over a year ago.  Patch is posted for review at https://gerrit.asterisk.org/7932.

By: Ludovic Gasc (Eyepea) (gmludo) 2018-01-12 00:47:23.922-0600


I'm not the reporter, however we are testing 15.2-rc2 on three servers, and we have seen also this stacktrace with the more or less the same frequency.

We have applied this patch two days ago, we don't have anymore crashes since the deployment.

No side effects observed for now.

By: Friendly Automation (friendly-automation) 2018-01-12 08:46:23.036-0600

Change 7932 merged by Joshua Colp:
chan_sip: Check that an iostream exists before accessing.


By: Friendly Automation (friendly-automation) 2018-01-12 08:52:43.897-0600

Change 7933 merged by Jenkins2:
chan_sip: Check that an iostream exists before accessing.