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

support upstream libxml2 master up to gnome/libxml2@05c147c3 #3161

Merged
merged 6 commits into from
Mar 22, 2024

Conversation

flavorjones
Copy link
Member

What problem is this PR intended to solve?

Closes #3156 and gets CI green against libxml2 master.

  • CDATA.new no longer accepts nil for content
  • update Node lifecycle to ensure the new libxml2 changes don't leak memory
  • update tests to reflect improved text coalescing

See commit logs for deeper explanations on these changes.

Have you included adequate test coverage?

Yes.

Does this change affect the behavior of either the C or the Java implementations?

Both C and Java implementations no longer accept nil for CDATA content.

This is proving to be useful when narrowing down which tests have memory leaks.
An upcoming libxml2 change will force us to make a behavioral change
of some kind, so I'm choosing to bring CData in line with the other
character data classes (Comment and Text).

The alternative would have been to continue accepting nil; but then
the constructed node would contain a blank string (currently in this
case Node#content returns nil). I think it's preferable to force
callers to be explicit here.

See upstream commit GNOME/libxml2@9991fae4
Upstream GNOME/libxml2@7e462425 updated `xmlAddChild` to do nothing if
the subject node's `->next` or `->prev` are non-NULL.

For fragments that are parsed in-node-context, the nodes are parsed as
siblings of each other, meaning that unless we explicitly set `next`
and `prev` to NULL, the node will not actually be inserted into the
tree by `xml_document.c:dealloc_node_i2` and so `xmlFreeDoc` will not
be able to free those nodes, resulting in a leak.
A text node coalescing bug was fixed in GNOME/libxml2@4ccd3eb8, and
although Nokogiri handles this fine from a memory perspective, the
tests need to be updated to reflect the new behavior.
@flavorjones flavorjones changed the title support upstream libxml2 master support upstream libxml2 master up to gnome/libxml2@05c147c3 Mar 22, 2024
@flavorjones flavorjones merged commit 97f2579 into main Mar 22, 2024
128 checks passed
@flavorjones flavorjones deleted the flavorjones-3156-upstream-libxml branch March 22, 2024 15:19
flavorjones added a commit that referenced this pull request Apr 7, 2024
**What problem is this PR intended to solve?**

Get upstream libxml2 integration tests passing again.
GNOME/libxml2@5bb84b47 changed behavior around text node coalescing
again. See related #3161.

Notably, with this change, blank text nodes are no longer merged by
`#add_{next,previous}_sibling`. See the tests originally added in
3c8c21e back in 2009 for some context.
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.

(upstream libxml2) test errors
1 participant