Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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:

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

<?php
    // blah.php
    print 'blah';
?>

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

top of index.php<br>
blah
<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, pastebin.com/kBg8uXfV 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 php.net, but any further insight you (or anyone else) could give is still appreciated. –  Chris Sep 6 '12 at 16:59

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.