debugging the XML_Serializer in PHP – Segmentation Fault jamboree

Had a vexing problem the other day, serializing a sub-component (processor) in my modeling suite, was causing a segmentation fault.  This was especially vexing since the larger object that contained these sub-components was serializing just fine.   The error in my apache httpd log was:

[Mon Nov 09 13:48:23 2009] [notice] child pid 24827 exit signal Segmentation fault (11)

The culprit?  An object reference to the “parent” container.  The sub-components all have a property called “parentobject” that contains a reference to their parent, in case they need to communicate (which they frequently do).  The serializer would break when it came time to serialize this guy if his parent object linkage was still their.  Perhaps this caused a recursion to occur, since the parent also contained the child, serializing the child would then serialize the parent which would then serialize the child…  or perhaps this XML_Serializer class just doesn’t like to serialize an object inside of an object?

Nevertheless, nullifying the parent object reference eliminated the error – which is not a problem when serializing, because you are just truing to store it, and the parent object reference would no longer persist anyhow.

Links:

XML_Serializer – a PEAR class that does a nice job of serializing complex objects (as long as you don’t make them recursive!)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s