Another case of PHP segfaulting. This time, at least, it was behaving deterministically and by inserting print "Meep!"; flush(); throughout various bits of the code I managed to track down the problem. It was segfaulting trying to read a config file to which it didn't have read permissions. PHP is bad.