sparklemotion/nokogiri

(upstream) libxml2 crashing

Closed this issue · 4 comments

Seeing crashes in the "upstream" CI, examples:

Both seem to have something to do with namespaces.

git bisecting reveals at least some crashes began with GNOME/libxml2@2840e33

Repro

#! /usr/bin/env ruby

require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "nokogiri", path: "."
end

attr = Nokogiri::XML.parse('<foo xml:bar="http://bar.com"/>').root.attributes["bar"]
attr.namespace # boom

This looks like it has to do with xmlSearchNS now returning a static struct if the namespace is xml?

Yeah ok, so the static struct xmlXmlNamespace is located in read-only memory.

$ objdump -t .libs/libxml2.so | fgrep xmlXml
000000000014f800 l     O .data.rel.ro   0000000000000030              xmlXmlNamespaceStruct
000000000015a1c8 l     O .data  0000000000000008              xmlXmlNamespace

which means that trying to set the _private member is going to segfault. I will bring this up with Nick in an upstream issue.

Nick reverted the commit upstream.