Bug 115033 - KDE apps have problems with name resolution
Summary: KDE apps have problems with name resolution
Status: RESOLVED WORKSFORME
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Thiago Macieira
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-25 00:28 UTC by David Johnson
Modified: 2006-08-08 17:26 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Johnson 2005-10-25 00:28:26 UTC
Version:            (using KDE KDE 3.4.3)
Installed from:    Ubuntu Packages
Compiler:          gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9) 
OS:                Linux

Since I upgraded my Kubuntu Hoary install to Breezy (going from KDE version 3.4.1 - I think - to 3.4.3) all KDE apps have had problems with name resolution.
For example, when KMail checks all mail it will randomly say 'Unknown host' for some of the accounts. Konqueror also fails to load random images or style sheets on web sites and Amarok often gives "unknown host" errors when accessing lyrics.

There are no issues with my DNS and no non-KDE applications have any name resolution problems whatsoever.

I have determined that this problem appears when I have a 'search' line in my resolv.conf. In this situation, KDE apps seem to ignore valid responses to DNS queries. My search domain is in the form my.search.co.uk.

Here's the output from Ethereal when KMail tries to check my two POP3S accounts, both at the same host (hence two DNS queries for the same host):

Standard query A mail.mydomain.co.uk
Standard query A mail.mydomain.co.uk
Standard query AAAA mail.mydomain.co.uk
Standard query AAAA mail.mydomain.co.uk
Standard query response <the correct IP>
Standard query response <the correct IP>
Standard query response
Standard query response
Standard query AAAA mail.mydomain.co.uk.my.search.co.uk
Standard query response, No such name
Standard query A mail.mydomain.co.uk
Standard query A mail.mydomain.co.uk
Standard query AAAA mail.mydomain.co.uk
Standard query response <the correct IP>
Standard query response <the correct IP>
Standard query response
Standard query AAAA mail.mydomain.co.uk.my.search.co.uk
Standard query response, No such name
Standard query A mail.mydomain.co.uk.my.search.co.uk
Standard query A mail.mydomain.co.uk.my.search.co.uk
Standard query response, No such name
Standard query response, No such name

At this point, KMail produces two 'unknown host' errors. As you can see, valid
responses containing the correct IP were returned not once but twice, but KMail
ignored them.
If I remove the 'search' line from my resolv.conf, the problems go away
completely. As I mentioned before, this problem affects all KDE apps, not just
KMail.

I also opened a bug about this at the Ubuntu bugzilla, but there have been no responses there:
http://bugzilla.ubuntu.com/show_bug.cgi?id=17692
Comment 1 Thiago Macieira 2005-10-25 03:46:14 UTC
The code that does this hasn't changed in two releases (since KDE 3.3). Especially not between KDE 3.4.1 and 3.4.3. So I this is certainly not a bug that was introduced.

It could be a bug that has been there all along, but I also doubt it.

Can you test one account only and paste the ethereal dump? You may also send the -w dump to my email, if you prefer.
Comment 2 David Johnson 2005-10-25 15:09:19 UTC
OK, here's the Ethereal output when checking one host, which I've found always works as expected and doesn't cause 'Unknown host' errors:

Standard query A mail.mydomain.co.uk
Standard query AAAA mail.mydomain.co.uk
Standard query response <the correct IP>
Standard query response
Standard query AAAA mail.mydomain.co.uk.my.search.co.uk
Standard query response, No such name
Standard query A mail.mydomain.co.uk
Standard query response <the correct IP>

The output is exactly the same when I don't have a search line, just without the query and response for mail.mydomain.co.uk.my.search.co.uk (so it still queries and gets a valid response for the domain twice).

I can still reproduce the 'Unknown host' errors when KMail is checking more than one account at the same, or different, domains.

I will send you the -w output by e-mail.
Comment 3 Thiago Macieira 2005-10-26 03:51:44 UTC
Indeed there's nothing that I can take from your ethereal dump (sent in private).

Can you reproduce this same problem in Konqueror? If you can, please try the following:

1) open Konqueror and get it ready to cause the error
2) run: killall kio_http
3) find kdeinit's PID
4) run: strace -f -o /tmp/trace -p kdeinits-PID
5) get Konqueror to cause the error
6) Ctrl+C the strace and send me the trace file
Comment 4 David Johnson 2005-10-26 11:36:42 UTC
Konqueror doesn't give any errors, but it fails to load most images/style-sheets on a page. It gives similar Ethereal output to the above when doing DNS queries.

I'll send you the trace file.
Comment 5 Thiago Macieira 2005-11-14 00:08:17 UTC
I've reread your trace after several days, with a fresh mind. I still cannot explain what I am seeing.

Here are the lines:
8720  sendto(9, "\22#\1\0\0\1\0\0\0\0\0\0\10slashdot\3org\0\0\1\0\1", 30, 0, NULL, 0) = 30
8721  recvfrom(10, "\22#\201\200\0\1\0\1\0\5\0\5\10slashdot\3org\0\0\1\0\1"..., 1024, 0, {sa_family=AF_INET,
sin_port=htons(53), sin_addr=inet_addr("192.168.50.1")}, [16]) = 235

Translation: DNS query of slashdot.org on socket fd 9 from thread with PID 8720, reply on fd 10 on another thread.

This cannot happen.

The only way of a reply coming in through the wrong socket is if:
a) both sockets had the same address (SO_REUSEADDR), but libresolv doesn't do that
b) the kernel got confused and sent the data to the wrong file descriptor
c) the name server sent the reply back to the wrong address
d) something in-between (a DNS proxy, or NAT or whatever) mixed up and moved the reply to the wrong address

The fact that the replies are coming in in the wrong sockets explains why name resolution sometimes fails: libresolv will send a query up to 3 times if it gets no answer. If the answers are being delivered to the wrong fd -- especially the wrong thread -- it will conclude that the NS server is unavailable and report as error.

So, I'm sorry, I don't know how to fix this bug. I'm stumped.
Comment 6 David Johnson 2005-11-15 01:36:40 UTC
hmmm, I'm not sure what to do next in that case. I can rule out my DNS and router hardware as the problem didn't exist until I upgraded my distribution (unless some change in the kernel/libresolv has triggered a bug in the router...).

The strange thing is that this bug only seems to affect KDE apps - FireFox, ping, ssh etc. all seem to work normally.

But it seems that I'm the only person seeing this bug, in which case it probably isn't worth spending too much time on. I can 'fix' it simply by commenting out my search line in resolv.conf, so it's not too big a deal. Thanks for your help in figuring out what's going on though!
Comment 7 David Johnson 2006-08-08 17:26:51 UTC
Closing this bug -- it only affects me so almost certainly isn't really a KDE bug.