Summary:ASTERISK-17573: Segmentation fault if address can't resolved
Reporter:Holger Hornung (netview)Labels:
Date Opened:2011-03-17 17:33:11Date Closed:2012-03-23 14:16:41
Versions:1.8.3 Frequency of
Description:[2011-03-17 23:17:40] ERROR[1702]: netsock2.c:245 ast_sockaddr_resolve: getaddrinfo("sip.terralink.de", "(null)", ...): Name or service not known
[2011-03-17 23:17:40] WARNING[1702]: acl.c:579 resolve_first: Unable to lookup 'sip.terralink.de'
[2011-03-17 23:17:40] WARNING[1702]: acl.c:422 ast_append_ha: Invalid IP address: (null)
Segmentation fault

a ping to sip.terralink.de gives no answer!
Comments:By: Alec Davis (alecdavis) 2011-03-20 03:02:30

unable to repeat
Tried with the following tag release

Assuming your using below in using sip.conf
register => 1234:password@mysipprovider.com

[2011-03-20 20:54:20.095354] ERROR[23838]: netsock2.c:245 ast_sockaddr_resolve: getaddrinfo("mysipprovider.com", "(null)", ...): Name or service not known
[2011-03-20 20:54:20.095450] WARNING[23838]: acl.c:579 resolve_first: Unable to lookup 'mysipprovider.com'
[2011-03-20 20:54:20.096621] WARNING[23838]: acl.c:708 ast_ouraddrfor: Cannot connect
[2011-03-20 20:54:20.097169] WARNING[23838]: chan_sip.c:3165 __sip_xmit: sip_xmit of 0x87eea50 (len 385) to (null) returned -1: Invalid argument

register => 1234:password@sip.terralink.de
seems to be working

A backtrace would, not forgetting to compile with DONT OPTIMIZE enabled

By: Leif Madsen (lmadsen) 2011-04-01 13:24:20

I also have not been able to reproduce. I have seen this, but Asterisk never crashes on me (1.8.4-rc2).

Please provide a backtrace per https://wiki.asterisk.org/wiki/display/AST/Getting+a+Backtrace

By: Holger Hornung (netview) 2011-04-01 18:27:45

It happened again (rev. 312509):

[2011-04-02 01:21:46] ERROR[2501]: netsock2.c:245 ast_sockaddr_resolve: getaddrinfo("sip1.speednetwork.de", "(null)", ...): Name or service not known
[2011-04-02 01:21:46] WARNING[2501]: acl.c:579 resolve_first: Unable to lookup 'sip1.speednetwork.de'
[2011-04-02 01:21:46] WARNING[2501]: acl.c:422 ast_append_ha: Invalid IP address: (null)

sorry - no backtrace available at this time!

By: Holger Hornung (netview) 2011-04-01 20:45:56

acl.c line 421
If I comment out the error-line no crash occurs:

if (!ast_sockaddr_parse(&ha->addr, address, PARSE_PORT_FORBID)) {
               ast_log(LOG_WARNING, "Invalid IP address: %s\n", address);
               /*if (error) {
                       *error = 1;
               return ret;

By: Holger Hornung (netview) 2011-04-01 20:59:55

additional Information: if asterisk is up and the error occurs, I saw only the error messages without any segfaults. Asterisk crashes reproducible after a 'sip reload' or 'core restart now' if a peer cannot be resolved.

By: Kinsey Moore (kmoore) 2011-08-18 13:52:32.375-0500

I am also unable to reproduce this issue and I can not find a place where error would be set but not a valid address since every instance of this function call in current trunk uses either NULL or a pointer to a stack variable.  For this issue to progress, we need a backtrace to work with.

By: Paul Belanger (pabelanger) 2011-08-23 10:30:44.108-0500

You should be able to add a unittest for this, checkout test_netsock2 for more information.  Once you can reproduce it with a unit test, upload the patch and we can get it fixed.

By: Matt Jordan (mjordan) 2012-03-23 14:16:47.332-0500

Thank you for the bug report. However I am unable to reproduce this issue. We are now going to close this report - please feel free to reopen when you have more information at hand.