The Linux Page

The White Screen of Death

White Screen of Death

Using Drupal happily and all of a sudden... nothing! A completely blank page, often called the White Screen of Death or WSOD.

Quite annoying situation, I have to say, but well... it happens.

There are several (many?) pages about the White Screen of Death (in reference to the Blue Screen of Death by our friend Microsoft.)

Debugging WSOD

In each case, somehow, PHP does not directly give you the necessary info to debug the problem.

I had that and got held up for 4 hours with the Rules module. The Rules module has a large set of files to include and they attempt not to include what they do not need so in general the whole module runs faster. Beside the fact that they use "include_once" instead of "require_once", if you have a file that cannot be included because of a PHP syntax error, you get NOTHING and the process stops. I have no clue why PHP won't talk to you back when it includes something and does not generate an error.

4h to notice that I was missing one semi-colon. PHP is stupid in this way. In C++ I would not be able to compile and I would get an error on the exact line immediately... And it is not that PHP does not give you the error, it does, if you directly load the very file with the error. But somehow, when run through the normal Drupal process it would not generate the error even with all the error turned on as follow:

// the test is to make sure the errors reporting only happens
// on the site that I'm working on and not all my sites 
if ($_SERVER['HTTP_HOST'] == 'test.example.com') {
  error_reporting(E_ALL);
  ini_set('display_errors', TRUE);
  ini_set('display_startup_errors', TRUE);
}

The easy way to test whether your file compiles:

php <filename>

But of course, you have to think that could be the problem!

JavaScript WSOD

Today I got a WSOD... after the screen loaded, It went from showing the top of the website and poof! Gone.

I looked into it some more but I just cannot figure it out. The problem is with the ShareThis module. Somehow the sharethis.js code fails and as it is at it, it writes an empty string to Document. In other words, it clears my screen. Not too sure what's wrong... It worked fine in Chrome though, but FireFox is going bananas.

Nothing to fix that one for me, but to go back to my site, I had to disable the module. To do so, I went to my database and wrote the following:

       UPDATE system SET status = 0 WHERE name = 'sharethis';

The name at the end is simply the name of the module conserned. The status is 1 when a module is enable. Setting it to 0 means that the module will not run anymore. You may miss the hook_disable() function call if there is one (it is rare.) Other than that, it will make your site work again.

Reasons for a WSOD

Most everything will not generate a WSOD. But the following are the few errors I experienced and that generated a WSOD with no error reporting from PHP:

  • Include a PHP file does not compile properly (syntax error)
  • Include a PHP file fails compiling because a function is redeclared (two functions with the same name)

Other people reported memory errors which usually are reported by the PHP error reporting.

Out of Memory Errors

Today I was hit by an out of memory error in Drupal.

The problem was that someone would use the site creating pages with very large images all defined inline. In general, it works, but when you put an image inline, it is about THREE times larger than an uploaded image.

Anyway, one of those images took some 3Mb of space quickly breaking the PHP limit which is not a bad thing...

Since the images "leaked" in the teaser, the blog main page was also dead (i.e. the blog page was over 128Mb with all of those images.)

I had to edit the database directly since the Edit command would fail too.