As it seems I get the segfault on large structures, after a few thousand inserts, at least it segfaults after ~ 50000 calls to the code above. The function triggering the error is the ->paster() bit.sub add_html { my $self = shift; my $ref = shift; # step over elements in fixed order my @elements; foreach my $key (qw(loc changefreq lastmod priority)){ if($key eq 'loc'){ if($ref->{loc}){ push(@elements, XML::Twig::Elt->new('l +oc', {}, $ref->{loc}) ); }else{ print "Error: 'loc' is a mandatory val +ue and missing!\n" } }elsif($key eq 'priority'){ if($ref->{priority}){ push(@elements, XML::Twig::Elt->new('p +riority', {}, $ref->{priority}) ); }else{ print "Error: 'priority' is a mandator +y value and missing!\n" } } } # wrap these sub-elements into an "url"-level my $elt = XML::Twig::Elt->new('url', {}, @elements); undef(@elements); # and add this url-sub-element nest to the xml-document $elt->paste(last_child => $self->{xml}); $self->{cnt}->{html}++; }
In reply to Segmentation fault from XML::Twig::Elt by isync
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |