The two articles Geo-IP: The DNS BL and Graphic DNSSEC in the TLDs Report rely on bits of code (both on the page and in the back-end) to perform a DNS lookup on a TXT record. I had to use the lowest common denominator in creating the back-end code so that I could test it on my Mac and later run it on the server that hosts this site. To make my life easier, and because the task is trivial, I chose to use a bit of PHP and the dns_get_record() function which fetches DNS resource records associated with the given domain name.

While I was testing the code on my Mac (the beauty of a Mac or Linux workstation being that I have a full UNIX development environment on it) my Web browsers would crash. All of them: Firefox, Chrome, and Safari. Actually it wasn’t really the browser that would crash, but rather the whole machine would stop reacting:

  1. The page would not complete loading.
  2. The fan started up.
  3. My Twitter client would show an NS-whatsit error-message
  4. I could quit only certain applications, while others wouldn’t quit.
  5. I could not launch new programs (no fork()/exec())
  6. And finally the whole workstation would become so unresponsive that, no matter how long I waited, I had to power off and restart.

I was convinced it was a problem with my jQuery code on the particular page, and even asked Stefan to test, but he couldn’t reproduce the issue. After tweaking the code to use synchronous callbacks, everything appeared to work, and I was relieved.

But that wasn’t it. I continued experiencing “crashes”, and on the 9^th or 10^th I was fuming.

I then suspected the local Apache server was acting up, and when I tested with the back-end code on a different machine I couldn’t reproduce the error, so I left it at that.

The final straw, and I’m finally getting to the problem, came last night, when I ran the following code snippet in a terminal with php -f snip.php:

    print_r(@dns_get_record('', DNS_TXT));

The machine crashed again, with the same symptoms I enumerated above. Aha! No Apache, no jQuery, so it is PHP?

That does indeed explain why we couldn’t reproduce the crashes when testing against different back-end servers, which don’t run on Mac OS/X.

I have no solution (apart from not using this particular function). There must be some funny interaction between dns_get_record(), PHP (PHP 5.3.4 (cli) (built: Dec 15 2010 12:15:07), and the Mac’s resolver (Mac OS/X 10.6.7). I can run the code a random number of times until the system becomes unresponsive.

My Twitter client displaying a name resolution error, should have alerted me to the fact it had nothing to do with the page running in the browser. I don’t think it is the resolver itself – I do lots of (sometimes strange) DNS queries against it, perhaps many more than most do, and I’ve yet to experience an outage due to it.

Can anybody reproduce this on their Macs?

Update: Thanks to all who tested this for me; it seems to be my problem only. :-
DNS, PHP, MacOSX, and crash :: 11 Jun 2011 :: e-mail