Reason:
This is caused by the associationXml string that is being passed to SharePoint’s internal method DoesWorkflowCancelWhenItemEdited, which basically returns a Boolean if the workflow is cancelled (it’s not really about what this method does, but the string argument that it’s expecting). This is just simply part of the check in SharePoint’s internal code to ensure the status of the workflow and the workflow item is ok.
However, this check is reading an associationXml string. This value refers to the Microsoft.SharePoint.Workflow.SPWorkflowAssociation.AssociationData. The problem is that this property value is null. Hence, when SharePoint try to read this XML style string into the hashtable, and then parse it as XML content into a StringReader it hits a NullReferenceException. All out of the box workflows has this data set so that’s why they work. This check is done only by Publishing sites.

Fix:
There is a workaround to this issue. We simply have to set a value to this AssociationData. The main issue is where should we do this? We can’t set it onWorkflowActivated because the workflow properties are read only at this point (hence the Properties.AssociationData cannot be updated). So we need to set it in the Elements.xml. The following can be implemented in the Elements.xml to work around this issue:
1. Remove the old workflow that’s currently associated with the library
2. Edit the Elements.xml file and include the text below right after the tag (this assumes that you are not using the association data in your workflow)

3. Redeploy the workflow to the library