Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Need Help: LibXML + LWP::Simple Is Making Perl Crash

Reply
Thread Tools

Need Help: LibXML + LWP::Simple Is Making Perl Crash

 
 
Jeff.M
Guest
Posts: n/a
 
      12-26-2007
I've been getting a very weird bug. No error message. perl simply
crashes. With lots of trial and error, I've narrowed down the parts
that cause the crash. Below is some very simple code that -- on my
WinXP comp with ActivePerl 5.8.8 -- will crash reliably.



use strict;
use warnings FATAL => 'all';

use XML::LibXML;
use LWP::Simple;


# The XML structure...
# <myroot>
# <somenode>
# <somedeepernode>Hello, World!</somedeepernode>
# </somenode>
# </myroot>
my $rootNode = XML::LibXML::Element->new('myroot');

my $someNode = XML::LibXML::Element->new('somenode');
$rootNode->appendChild($someNode);

my $someDeeperNode = XML::LibXML::Element->new('somedeepernode');
$someDeeperNode->appendText('Hello, World!');
$someNode->appendChild($someDeeperNode);



my @someNodes = $rootNode->getElementsByTagName('somenode');
foreach my $someNode (@someNodes)
{
# If this line is commented, then all is good.
# But if it's left in... crash.
my $theText = $someNode->findvalue('somedeepernode');

# This line -- a different way to accomplish
# the same thing -- would crash too.
# my $theText = $someNode->getElementsByTagName('somedeepernode')-
>get_node(1)->nodeValue;

}



# Or if this line is commented, then all is good also. But because
I've had
# other weirdness with getting text from XML nodes, I'm leaning toward
LibXML
# being the culprit.
my $x = get('http://www.perl.com');



print q`If you're reading this, then it worked!`;
 
Reply With Quote
 
 
 
 
Ivan Novick
Guest
Posts: n/a
 
      12-26-2007
On Dec 25, 8:24 pm, "Jeff.M" <(E-Mail Removed)> wrote:
> I've been getting a very weird bug. No error message. perl simply
> crashes. With lots of trial and error, I've narrowed down the parts
> that cause the crash. Below is some very simple code that -- on my
> WinXP comp with ActivePerl 5.8.8 -- will crash reliably.
>
> use strict;
> use warnings FATAL => 'all';
>
> use XML::LibXML;
> use LWP::Simple;

-- snip --

There are clearly issues/bugs with XML::LibXML.

I have run your program via valgrind memory profiler on a debian
system with perl 5.8 and there are numerous illegal memory usages
coming from the LibXML library.

Here is an example:
==2253== Invalid read of size 4
==2253== at 0x48338E6: domXPathFind (in /usr/lib/perl5/auto/XML/
LibXML/LibXML.so)
==2253== by 0x4814705: XS_XML__LibXML__Node__find (in /usr/lib/
perl5/auto/XML/LibXML/LibXML.so)
==2253== by 0x80BDAC0: Perl_pp_entersub (in /usr/bin/perl)
==2253== by 0x80BC398: Perl_runops_standard (in /usr/bin/perl)
==2253== by 0x8063BFC: perl_run (in /usr/bin/perl)
==2253== by 0x805FFD0: main (in /usr/bin/perl)
==2253== Address 0x476C534 is 20 bytes inside a block of size 88
free'd
==2253== at 0x401CFA5: free (vg_replace_malloc.c:233)
==2253== by 0x44093D6: xmlFreeDoc (in /usr/lib/libxml2.so.2.6.27)
==2253== by 0x483388D: domXPathFind (in /usr/lib/perl5/auto/XML/
LibXML/LibXML.so)
==2253== by 0x483393A: domXPathSelect (in /usr/lib/perl5/auto/XML/
LibXML/LibXML.so)
==2253== by 0x48141D6: XS_XML__LibXML__Node__findnodes (in /usr/lib/
perl5/auto/XML/LibXML/LibXML.so)
==2253== by 0x80BDAC0: Perl_pp_entersub (in /usr/bin/perl)
==2253== by 0x80BC398: Perl_runops_standard (in /usr/bin/perl)
==2253== by 0x8063BFC: perl_run (in /usr/bin/perl)
==2253== by 0x805FFD0: main (in /usr/bin/perl)

I would recommend using another module for XML handling and submitting
a bug to the maintainer of this package.

Regards,
Ivan Novick
http://www.0x4849.net
 
Reply With Quote
 
 
 
 
Todd Wade
Guest
Posts: n/a
 
      12-31-2007
On Dec 26, 12:30*am, Ivan Novick <(E-Mail Removed)> wrote:
> On Dec 25, 8:24 pm, "Jeff.M" <(E-Mail Removed)> wrote:
> > I've been getting a very weird bug. No error message. perl simply
> > crashes.

>
> There are clearly issues/bugs with XML::LibXML.
>
> I have run your program via valgrind memory profiler on a debian
> system with perl 5.8 and there are numerous illegal memory usages
> coming from the LibXML library.
> ...
> I would recommend using another module for XML handling and submitting
> a bug to the maintainer of this package.


Wow. XML::LibXML is broken? Bummer.

http://groups.google.com/group/comp....1364d8f1816315
 
Reply With Quote
 
pajas@matfyz.cz
Guest
Posts: n/a
 
      01-01-2008
Hi Ivan, Jeff ,Todd,

XML::LibXML has a maintainer (me), so if you see something like this,
you better report it via rt.cpan.org than cry on usnet forums. Anyway,
I can confirm this problem exists with version 1.65 and earlier, but
in the SVN, it has been already fixed (due to somebody else's
report).

And by the way, the problem with the example code is that you do not
create a document node first. Make it

my $doc = XML::LibXML:ocument->new;
$doc->createElement(...)

and things will start to work with 1.65 too.

Please wait for the next release or refer to
http://search.cpan.org/src/PAJAS/XML-LibXML-1.65/README
on how to install from SVN (the README assumes POSIX-like environment,
I fear it may be a bit trickier on windows).

-- Petr

Todd Wade wrote:
> On Dec 26, 12:30�am, Ivan Novick <(E-Mail Removed)> wrote:
> > On Dec 25, 8:24 pm, "Jeff.M" <(E-Mail Removed)> wrote:
> > > I've been getting a very weird bug. No error message. perl simply
> > > crashes.

> >
> > There are clearly issues/bugs with XML::LibXML.
> >
> > I have run your program via valgrind memory profiler on a debian
> > system with perl 5.8 and there are numerous illegal memory usages
> > coming from the LibXML library.
> > ...
> > I would recommend using another module for XML handling and submitting
> > a bug to the maintainer of this package.

>
> Wow. XML::LibXML is broken? Bummer.
>
> http://groups.google.com/group/comp....1364d8f1816315

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ libraries: Xerces, libxml/libxml++ or perhaps Arabica? Olav XML 3 01-20-2005 02:51 PM
cant install libxml::perl p cooper Perl 0 01-10-2004 12:23 PM
catm install libxml::perl p cooper Perl 0 01-10-2004 06:18 AM
CRASH - DirectX End-User runtime - CRASH - What to to ? reply@newsgroup.please Computer Support 1 01-05-2004 02:55 PM
Problems with libxml, XML::LibXML and Perl Ian Gregory XML 1 07-25-2003 04:20 PM



Advertisments