Modify

Opened 6 years ago

Closed 4 years ago

Last modified 2 years ago

#11929 closed defect (fixed)

asterisk 1.8.10.1 hangs when resolving dns in register, trunk r32786

Reported by: arpena@… Owned by: developers
Priority: normal Milestone: Chaos Calmer 15.05
Component: toolchain Version: Trunk
Keywords: asterisk dns register Cc:

Description

Hi there!

I found an issue when upgrading my DIR-825 to latest trunk. Asterisk failed to register to my voip provider, and no other UDP SIP phone would register with it. Also, asterisk cpu utilization went to 100%.

My sip.conf looked like this:

[general]
...
register => user:pass@voip-provider.com/number

[phone1]
type=friend
host=dynamic
...
[voip_provider]                                            
type=peer                                                       
host=voip-provider.com
...

With strace I saw this repeating all the time:

1837  open("/etc/resolv.conf", O_RDONLY) = 11
1837  ioctl(11, SNDCTL_TMR_TIMEBASE or TCGETS, 0xb72180b4) = -1 ENOTTY (Inappropriate ioctl for device)
1837  read(11, "search lan\nnameserver 127.0.0.1\n", 4096) = 32
1837  read(11, "", 4096)                = 0
1837  close(11)                         = 0

Changing the register line to:

register => user:pass@ipaddress/number

worked around the issue.

Interestingly, the peer connected without problems even with the dns name in the 'host=' line, the problem is only with the 'register =>" line.

Attachments (1)

560-res_init_asterisk.patch (2.4 KB) - added by marko 5 years ago.
patch reordering res_init to fix asterisk dns hangup

Download all attachments as: .zip

Change History (18)

comment:1 Changed 6 years ago by arpena@…

Tested this issue in a vmware image of trunk with the same results.

comment:2 Changed 5 years ago by dgolle@…

I can observe the same behaviour on recent trunk on kirkwood. It seems to be uclibc related, as also resolveip hangs, though the same host is resolvable using nslookup.

comment:3 Changed 5 years ago by diegomanas.dev@…

I sill can see this happening in r33883(beta2). However, I think was perfectly working on beta. I may be wrong as I been playing with differen images lately. I'll try downgrading to beta this weekend and report back.

comment:4 Changed 5 years ago by dgolle@…

#12290 seems to be a more generic duplicate of this bug.

comment:5 Changed 5 years ago by diegomanas.dev@…

Nope, Beta does not work either. It may be that I saw it working when I ran dd-wrt + opkg. Is there any fix for this issue? I'm eager to test any solution we discuss over here.
Thanks a lot!

comment:6 Changed 5 years ago by sjoerdmulder@…

Any updates on this? Hit this issue today, also tried the current "trunk" build and it is still there

Changed 5 years ago by marko

patch reordering res_init to fix asterisk dns hangup

comment:7 Changed 5 years ago by marko

I've tried locating this issue in 12.04rc1, and located an issue in uClibc 0.9.33.2 resolv.c . Asterisk just does this from thread 2 in dns.c:

	ast_mutex_lock(&res_lock);
	res_init();
	res = res_search(dname, class, type, answer, sizeof(answer));

res_search then hangs up with 100% cpu in a loop:


again:
	__UCLIBC_MUTEX_LOCK(__resolv_lock);
	_res_options = _res.options;
	_res_ndots = _res.ndots;
	_res_dnsrch = _res.dnsrch;
	__UCLIBC_MUTEX_UNLOCK(__resolv_lock);
	if (!(_res_options & RES_INIT)) {
		res_init(); /* our res_init never fails */
		goto again;
	}

The reason is that somehow _res.options is never set with the RES_INIT flag. That is becuase res_init() in uClibc's resolv.c has a different _res global than res_search due to a redefinition of _res in resolv.c .
I find 2 separate redefinitions of _res in resolv.c, both to me that look like more functions in resolv.c might have similar issues. I'm not sure what the redefinitions do.

There is a comment just above the 2nd _res redifitions that claims it should be after res_init() - but that piece is moved around after res_init(). So here is a small patch to re-shuffle res_init before that redefinition. This worked for me, my asterisk has no more DNS resolving issues.
Now I'm not claiming that this wont break something else, as I'm not sure why there are 2 redefinitions of _res in the first place...

comment:8 Changed 5 years ago by m.sedeshev@…

Hi all. I've tried to compile a asterisk with patch, but had a error. Then I patched by hand a resolv.c but when I compiled asterisk I have the same dns problem.
What shall I do to make it works?

comment:9 Changed 5 years ago by Bobby Boucher <openwrt@…>

I have a similar buy with IAX.
Issuing "iax2 reload" command make asterisk take 100% of the CPU.
A workarround is to change all hostnames by their IP address in iax.conf.

comment:10 Changed 5 years ago by renoir

Patching resolv.c in uClibc the way marko suggested + make dirclean solves the problem in trunk 37623 and asterisk 1.8.10

comment:11 Changed 4 years ago by graaly

I have this problem still on trunk 37907 with Asterisk 11. As soon as I set IP addresses for the hosts the problem is solved. Can there be a reason it doesn't work still with Asterisk 11?

comment:12 Changed 4 years ago by slachta

This issue is discussed at uClibc mailing list.

http://lists.uclibc.org/pipermail/uclibc/2013-August/047885.html

comment:13 Changed 4 years ago by Damian Kaczkowski <damian.kaczkowski+openwrt@…>

Just a note. Here are some more reports related to this(?) uClibc bug: #10285 #13022 #13685 Hope you get it fixed asap.

comment:14 Changed 4 years ago by zouhair.s@…

reported here too /ticket/14370.html.
temporary fixed with 560-res_init_asterisk.patch​
waiting for clean fix...

comment:15 Changed 4 years ago by anonymous

should be fie on uClibc master, thanks!

comment:16 Changed 4 years ago by slachta

  • Component changed from packages to toolchain
  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker (trunk)
  • Resolution set to fixed
  • Status changed from new to closed

It was backported from uClibc master and fixed in /changeset/39177.html. Please test if it does work for you.

Last edited 4 years ago by slachta (previous) (diff)

comment:17 Changed 2 years ago by jonaserik@…

Sorry to comment back here, and sorry for the poor question, but how do I apply the .path on OpenWrt Atttitude Adjustment12.09.

Thanks
Jonas

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.