libxml-raku / LibXML-raku

Raku bindings to the libxml2 native library
Artistic License 2.0
11 stars 5 forks source link

Assigning LibXML::Document to LibXML typed variable segfaults #33

Closed dwarring closed 4 years ago

dwarring commented 4 years ago

Parsing of a file with a trailing comment:

my LibXML $dom .= parse: :string(q:to<OUCH>);
<Document/><!-- A comment -->
OUCH
$ perl6-gdb-m -I . /tmp/parse.t
...
(gdb) bt
#0  0x00007ffff79ad1db in get_attribute ()
   from //home/david/git/rakudo/install/lib/libmoar.so
#1  0x00007ffff793f634 in MVM_interp_run ()
   from //home/david/git/rakudo/install/lib/libmoar.so
#2  0x00007ffff7a399a7 in MVM_vm_run_file ()
   from //home/david/git/rakudo/install/lib/libmoar.so
#3  0x00005555555554d2 in main ()

A leading comment also causes a similar segfault.

dwarring commented 4 years ago

Here's how Perl 5 XML::LibXML handles this:

 perl -MXML::LibXML -E'say XML::LibXML->new->parse_file("/tmp/doc.xml")->documentElement->nodeName'
Document
dwarring commented 4 years ago

Misdiagnosis. This works:

use LibXML;
my LibXML::Document $dom .= parse: :string(q:to<OUCH>);
<Document/><!-- comment -->
OUCH