nokogori
gem comes with its own version of libxml2
. Moreover it warns about libxml2.so
of a different version being loaded before it was required:
if compiled_parser_version != loaded_parser_version
["Nokogiri was built against LibXML version #{compiled_parser_version}, but has dynamically loaded #{loaded_parser_version}"]
It basically compares LIBXML_DOTTED_VERSION
macro and xmlParserVersion
global variable:
rb_const_set( mNokogiri,
rb_intern("LIBXML_VERSION"),
NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION)
);
rb_const_set( mNokogiri,
rb_intern("LIBXML_PARSER_VERSION"),
NOKOGIRI_STR_NEW2(xmlParserVersion)
);
And I'm experiencing it firsthand. When rmagick
(which dynamically links to libxml2.so
, ldd
confirms that) is required before nokogiri
, the latter complains.
From what I can see nokogiri
is linked to libxml2
statically. First that is the default (supposedly). Then when rmagick
is not required I can't see libxml2.so
in /proc/PID/maps
. I neither can see another version of libxml2.so
. ldd
doesn't list libxml2.so
as a nokogiri.so
's dependency. objdump
lists xmlReadMemory
(and friends) as a nokogori.so
's symbol (probably a sign that it was linked statically).
So how come can nokogiri
access libxml2.so
's variables? Does that mean that loading libxml2.so
overrides any statically linked versions? Can that happen in the middle of code execution?
nokogiri.so
is linked statically tolibxml2
. And I'm sure thatrmagick.so
is linked dynamically tolibxml2
. Ruby loadsnokogiri.so
andrmagick.so
when they arerequire
d. – Eberhart