[Home]

Summary:ASTERISK-26772: Crash in srv.c on startup with pjsip
Reporter:nappsoft (nappsoft)Labels:
Date Opened:2017-02-07 06:40:25.000-0600Date Closed:2017-02-08 09:15:40.000-0600
Priority:MajorRegression?Yes
Status:Closed/CompleteComponents:Core/DNS
Versions:13.14.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Linux gcc 4.9.3 musl 1.1.15Attachments:( 0) backtrace.txt
( 1) srv_lookup.patch
Description:First of all: version is 13.14.0-rc1, but this version does not seem to exist yet in the bugtracker...

And now about the issue: As soon as I configure a host with a hostname instead of an ip in pjsip.conf (registration, aor and identify section) asterisk 13.14.0-rc1 crashes during startup. This didn't happen with 13.13.1 as res_pjsip_endpoint_identifier_ip.c did not use ast_srv_lookup.

I'm able to work around the issue by either using IP addresses instead of hostnames or by applying the attached patch.

Backtrace attached
Comments:By: Asterisk Team (asteriskteam) 2017-02-07 06:40:25.842-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: nappsoft (nappsoft) 2017-02-07 08:31:33.445-0600

I've looked a bit deeper into the issue in the meantime. The crash happens when ast_search_dns returns with 0 what means that there were no matches.

maybe the following line of ast_srv_lookup:

if ((ast_search_dns(*context, service, C_IN, T_SRV, srv_callback)) < 0) {

should be changed to:

if ((ast_search_dns(*context, service, C_IN, T_SRV, srv_callback)) < 1) {

?


By: Joshua C. Colp (jcolp) 2017-02-07 11:54:11.903-0600

[~nappsoft] I believe that change of 0 to 1 is correct. Would you like to submit a change to Gerrit, or should I do so?

By: Joshua C. Colp (jcolp) 2017-02-07 12:13:51.736-0600

I actually tweaked the fix some more and now have it up for code review.

By: nappsoft (nappsoft) 2017-02-07 14:45:19.966-0600

Great, thanks! Just applied your patch for testing (was using my version before), it seems to be working as well.

By: Friendly Automation (friendly-automation) 2017-02-08 09:15:41.481-0600

Change 4897 merged by Joshua Colp:
srv: Fix crash when ast_srv_lookup is used and 0 records are returned.

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

By: Friendly Automation (friendly-automation) 2017-02-08 09:54:24.370-0600

Change 4900 merged by zuul:
srv: Fix crash when ast_srv_lookup is used and 0 records are returned.

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

By: Friendly Automation (friendly-automation) 2017-02-08 09:54:26.035-0600

Change 4901 merged by zuul:
srv: Fix crash when ast_srv_lookup is used and 0 records are returned.

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

By: Friendly Automation (friendly-automation) 2017-02-08 10:01:08.410-0600

Change 4899 merged by zuul:
srv: Fix crash when ast_srv_lookup is used and 0 records are returned.

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

By: Friendly Automation (friendly-automation) 2017-02-08 10:16:39.184-0600

Change 4898 merged by zuul:
srv: Fix crash when ast_srv_lookup is used and 0 records are returned.

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