PHPUnit Segmentation fault

Viewed 26440

When a PHPUnit test fails normally on my dev box (Linux Mint), it causes a "Segmentation Fault" on my Continous Integration box (Centos). Both machines are running the same version of PHPUnit. My dev box is running PHP 5.3.2-1ubuntu4.9, and the CI is PHP 5.2.17. I'd rather leave upgrading the PHP as a last resort though.

As per this thread: PHPUnit gets segmentation fault I have tried deactivating / reinstalling Xdebug. I don't have inclue.so installed.

On the CI box I currently only have two extensions active: dom from php-xml (required for phpunit) and memcache (required by my framework), all the others have been turned off.

13 Answers

Infinite recursion is normally what causes this issue for us. The symptoms of infinite recursion seem to be different when running code under phpunit, than they are when running it in other environments.

If anyone comes across this in relation to PHPunit within Laravel

It took a while to figure out what the issue was. I was going over the differences between my current code and the previous revision and through some trial and error finally got there.

I had two different models that were both including each other with the protected $with override.

This must have been causing some kind of loop that phpunit could not deal with.

Hopefully someone finds this useful.

if you have an object with property pointing to the same object, or other sort of pointer loops, you will have this message while running

serialize($object);

And if you are a Laravel user, and you are dealing with models. And if you think, you will never have this problem, because you avoiding pointer loops by using $hidden property on your models, please be advised, the $hidden property does not affect serialize, it only affects casting to JSON and array.

I had this problem, when I had a model saved into a property of a Mailable object.

fixed with

$this->model->refresh(); 

in a __construct method , just before the whole object is serialized.

Related