When running a particular piece of PHP code I am getting a segmentation fault in Apache2. The exact error is Program terminated with signal 11, Segmentation fault.
After enabling core dumps and using sudo gdb apache2 -core /tmp/apache2-gdb-dump/core
to analyze the core dump I got the result which can be obtained here http://pastebin.com/WetihWU0. Apparently something goes wrong with spl_array.c
.
I narrowed it down to a piece of PHP code which uses a method generated by Propel 1.7. The piece of code removes a crossreference entry of a particular class:
foreach($record->getCrossReferences() as $crossReference) {
$record->removeCrossReference($crossReference);
}
The error does not occur if I call removeCrossReference()
outside the loop. Weird eh?
Since PHP crashes on some c code I find it hard to obtain a minimal code sample which produces the segfault. Does anyone happen to know what causes the segfault? Or maybe give me some pointers towards getting a minimal code sample? I don't think the guys at PHP.org accept a bug report without a minimal code sample.
Versions I use:
$ php -v
PHP 5.3.10-1ubuntu3.8 with Suhosin-Patch (cli) (built: Sep 4 2013 20:05:42)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
$ /usr/sbin/apache2 -v
Server version: Apache/2.2.22 (Ubuntu)
Server built: Jul 12 2013 13:38:21
Propel version 1.7.0-dev
Interesting fact is that I also have an Arch machine with newer versions of Apache and PHP. On this machine the fault does not occur. But I don't know if this is due to newer versions or different configurations between the Arch and Ubuntu machine.