Hello,

I am trying to edit a xml file using XML::Twig, but perl always crashes on outputting the xml to a new file. Now, this already happens when I don't do anything to the file, just parse it and print it to another file. I've traced the problem to the cleanup routine in XML::Twig using the Devel::ptkdb debugger, it happens somewhere in the vicinity of line 7535 in Twig.pm (I use the newest version 3.39 of XML::Twig, and strawberry perl 5.12.3).

Sometimes there's also a memory leak and I get a message "Out of memory!". The crash itself doesn't produce any error messages in perl, aside from the message in Windows 7 that perl.exe has crashed.

The xml file can be found here: http://dl.dropbox.com/u/14595053/test.zip (45 kb, 1.7 MB expanded). I have zipped it and uploaded it to dropbox because it's quite big. I have validated it with several tools and all say, that it's a valid xml file.

use strict; use warnings; use XML::Twig; my $xml = new XML::Twig(); $xml->parsefile('test.xml'); open OUT, ">", "test.new.xml"; $xml->print(\*OUT); close OUT;
Does anybody know, what's going on? Thanks!

Edit: The workaround I found is to downgrade to perl 5.10.1.5.


In reply to perl crashes when processing xml with XML::Twig by justibus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.