Get ready for a long, boring read. I normally don’t delve into the depths that I’m about to, but after very little results on searching for a segmentation fault issue, I wanted to document the experience for future programmers.
We were experiencing segmentation faults on our latest web portal release, which uses Zend Framework 1.9.5 and PHP 5.3.5. The faults only occurred on our heaviest page, and it would only happen 50% of the time. The screen would be blank or partially loaded, no errors would appear in the PHP logs, and the Apache error logs would display some variation of:
[notice] child pid 3894 exit signal Segmentation fault (11)
After many hours of research, debugging, and narrowing down the lines of code that were effecting the server, it ended back at a snippet of code that has been used since the beginning to quickly create pulldown windows for AJAX prompts.
$select = new Zend_Form_Element_Select($key, array(
‘multiOptions’ => $options,
‘value’ => $value));
When this snippet was echo’d in the view, from my understanding, it’d create a rather large memory dump between negotiating back and forth between the form and view object.
This compounded with some known memory management issues in PHP 5.3+ to result in random segmentation faults on our server.
This fix was to return a string render of the select instead of the object itself, avoiding any confusion in the view when rendering.
The issue cannot be recreated in PHP 5.2+ and it has not been tested with any other version of Zend Framework. I hope you enjoyed sitting through my nightmare of the last day.