Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a server running FreeBSD 8.3-RELEASE-p3, Apache 2.2.22 from ports, PHP version 5.4.6 from ports, output is being garbled on the second load of a script. The problematic behavior was only detected today, but we suspect it began with a recent ports update.

Here is an example script:

    // index.php
    print 'top of index.php<br>';
    require 'blah.php';
    print '<br>after require';

    // blah.php
    print 'blah';

The first time after the file is modified, this is the output:

top of index.php<br>
<br>after require

The second (and any subsequent call) to that same script gives random garbage output like this ö or àœ~cept-Encodin or ðš~~~`... basically, scrambled junk. Sometimes it is chunks of the filename.

In the Apache error logs, we're seeing segfaults and PHP errors that function "\x0" is not defined, pointing at line 1 in index.php above. Obviously, print is a defined function!

If one saves the file (causes the ctime to change), the next load will again display the expected output, but again any subsequent loads are garbled. Restarting the server accomplishes this, except sometimes you can get 3-4 loads before the scrambling occurs.

I suspect there is an issue with gzip or zlib some other compression or opcode cache or the like. However, our php.ini is exactly the same as another server with the same setup and versions that works perfectly fine.

If someone could point me at a possible cause, or an effective way to further diagnose the issue, I'd appreciate it. I've checked the php.ini settings, set up a minimum sample, and verified that zlib is OFF -- no dice.

share|improve this question
Could you share your phpinfo()? How do you manage your software? With packages or ports? How did you do the problematic upgrade? – anders Sep 6 '12 at 16:47
Sure, I have found a condition that apparently resolves the issue. It seems that the trouble is related to APC, and by moving the extension load order (APC was last, changed to first), the issue ceases. I am doing due diligence before filing a bug report to, but any further insight you (or anyone else) could give is still appreciated. – Chris Sep 6 '12 at 16:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.