I am having a problem with my PHP process crashing whenever I try to connect to MongoDB from inside PHP.
$options = array(
'replicaSet' => false,
'persist' => false,
'connect' => false,
'username' => false,
'password' => false
);
$mongo = new \Mongo('mongodb://localhost:27017', $options);
The following php-cli code works fine though:
$ php -a
php > $mongo = new \Mongo('mongodb://localhost:27017');
php > var_dump($mongo);
object(Mongo)#1 (4) {
["connected"]=>
bool(true)
["status"]=>
NULL
["server":protected]=>
string(25) "mongodb://localhost:27017"
["persistent":protected]=>
NULL
}
However, there is nothing in the PHP error log when this happens (If I throw an exception right before it, that exception is logged). However, the FPM and syslogs catch the following entries. It’s as if PHP just flips out and crashes before anything can be logged.
php5-fpm.log: WARNING: [pool www] child 9261 exited on signal 11 (SIGSEGV)
after 57.894803 seconds from start
syslog: localhost kernel: [12191.961070] php5-fpm[9261]: segfault at 8 ip
00007f5329b1b371 sp 00007fff37343b68 error 4 in libc-2.13.so[7f5329a97000+197000]
- PHP Version 5.3.6-13ubuntu3.8 (API 20090626)
- MongoDB 1.2.10 extension
- Suhosin v0.9.32.1
How can I debug what appears to be an actual bug?
Update:
I just upgraded my OS to ubuntu 12.04 LTS
- PHP Version 5.3.10-1ubuntu3.2 (API 20090626)
- MongoDB 1.2.12 extension
- Suhosin v0.9.33
However I still have the problem.
syslog: kernel: [ 6727.997940] php5-fpm[9012]:
segfault at 8 ip 00007f1fdf8cab91 sp 00007fff7f07a4a8 error 4
in libc-2.15.so[7f1fdf842000+1b3000]
It seems that the problem lay with Mongo’s handling of my
$optionsarray.Crashes the process while the following works
Basically, don’t pass a username or password unless you need too. I guess this really is a bug.