Child processes and segmentation faults (Apache)


I know this is a long shot, but I thought to give it a try.

In my development PC, I run 64-bit Gentoo with Apache 2.2.11 and PHP 5.2.9. Apache uses the worker module to serve requests. During the development of the application I've been dealing with the last few weeks, I get a blank page after submitting a form. This mostly happens when I have a form with some attributes and submit it. Looking at Apache's logs, I get messages like that:

[tt][Mon May 25 18:23:53 2009] [notice] child pid 17353 exit signal Segmentation fault (11)[/tt]

Which is the pid of the process that handles the form submission request. Going back and hitting 2-3 times the submit form button, it works. The thing is that it starts to get annoying, as the code that handles the form submission gets bigger. This is not a memory issue (memory_limit is set to 64MB) and using the xdebug peak memory usage report function, I get usages of <8MB while sering a request.

The funny thing is that this problem is more intense when using the Opera browser. Switching to Firefox seems to degrade the problem, but it is not eliminated.

Any clues where to look? It this something of bad code practice? Is it because of Yii? Is it a configuration issue?

Any replies will be greatly appreciated! :)

Thanks in advance!

This should be a PHP (core or extension) issue because theoretically your PHP script should never cause a segmentation fault. I suggest you reinstall your PHP and extensions.

OK, I did some tests. Gentoo is a source-based Linux distribution, with the advantage that you can tweak your system configuration, that is, compile the packages as you see fit.

I compiled Apache with the prefork module and restarted it. I run the ab tool and guess what. Prefork is faster than worker, some 10% approximately (and supposedly worker should perform better on multi-core cpus, mine is a Intel Core 2 Duo E8400, with two cores). I instructed ab to call Yii’s entry script (index.php), so it’s pretty close to real world performance. It also seems to eliminate the segmentation issues (so far).

However, I will try to compile Apache again with the worker module and re-compile PHP and see how it goes.

I lied. Worker is faster. Running multiple times the ab command, worker is somewhat 8-10% faster than prefork. However, I think prefork is more stable in my configuration, so I will go with it.