require 'libxml' x = LibXML::XML::Parser.string("").parse r1 = x.find("/root") # if you comment out this line, script will NOT segfault puts r1.object_id r2 = x.find("/root")#.length # segfault occurs here puts puts r2.object_id