Looks like your experiencing this: http://issues.ez.no/IssueView.php?Id=12285&activeItem=61
My workaround for the specific customer where I ended up in this was to make sure I didn't use the $object variable after the xml attribute is shown (witch contains a nested embed object).