Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SR-8560: XMLDocument on Linux crashes with a Segmentation Fault #1664

Merged
merged 1 commit into from Aug 22, 2018

Conversation

spevans
Copy link
Collaborator

@spevans spevans commented Aug 20, 2018

  • When returning an XMLNode, take a reference to the parent
    XMLDocument to prevent the underlying libxml xml document
    from being freed.

  • This prevents the document being freed if a reference is still
    held to a XMLNode but not the XMLDocument.

- When returning an XMLNode, take a reference to the parent
  XMLDocument to prevent the underlying libxml xml document
  from being freed.

- This prevents the document being freed if a reference is still
  held to a XMLNode but not the XMLDocument.
@spevans
Copy link
Collaborator Author

spevans commented Aug 20, 2018

@swift-ci please test

@spevans spevans requested a review from phausler August 20, 2018 20:29
@parkera
Copy link
Member

parkera commented Aug 21, 2018

Looks good to me.

@spevans
Copy link
Collaborator Author

spevans commented Aug 22, 2018

@swift-ci please test and merge

@swift-ci swift-ci merged commit 64fb44a into apple:master Aug 22, 2018
@@ -790,6 +793,11 @@ open class XMLNode: NSObject, NSCopying {
withUnretainedReference {
_CFXMLNodeSetPrivateData(_xmlNode, $0)
}
if let documentPtr = _CFXMLNodeGetDocument(_xmlNode) {
if documentPtr != ptr {
_xmlDocument = XMLDocument._objectNodeForNode(documentPtr)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this create a cyclic strong reference? The document has a reference to its children, and children have a reference to the document. The objects will never be deallocated unless you detach all the children to break the cycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants