Filina Consulting

Fixing Doctrine Segfaults

March 21st, 2016

I had a tricky segfault when trying to save a very simple Doctrine object. Here's my debugging process and solution.


I was using the sabre/vobject package to parse and save some iCal data. The parsed data was assigned to properties of a Doctrine entity and then persisted. The segmentation fault was happening every single time I called the entity manager's flush() method.


After reading this answer on StackOverflow, I started to wonder whether something was wrong with the contents of the entity. So I used this utility method to inspect it (don't just var_dump as you'll get too much output):


What did I see? Instead of being a simple string, the summary was a Sabre\VObject\Property\FlatText. Obviously Doctrine wasn't able to deal with that type and something exploded in the process.


The solution was really simple. Just cast the property to string before assigning:

$event->summary = (string)vobject->SUMMARY;


This is a good reminder to double-check your entities before persisting them, especially when you get data from libraries with which you're not quite familiar.

Happy coding!


txyoji March 24th, 2016 Anything that can create a segfault is probably a bug in php itself.
Looking forward to a post about your experience reporting this bug to the php community.
Anna April 1st, 2016 It's possible that there's a bug somewhere. However, to report it, I'd have to dig through Doctrine to see what exactly is causing it and I don't have that kind of time right now. Avoiding the issue by casting is easier.

This page is protected by reCAPTCHA and the Google
Privacy Policy and Terms of Service apply.

Twitter: @afilina | E-mail: