Fixing Doctrine Segfaults

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:


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!

2 thoughts on “Fixing Doctrine Segfaults

  1. txyoji

    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.

    • 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">