ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: LibXML, LibXSLT free(): invalid pointer error
by rrathmann other posts by this author
Nov 21 2005 1:19PM messages near this date
view in the new Beta List Site
LibXML, LibXSLT free(): invalid pointer error | Re: LibXML, LibXSLT free(): invalid pointer error
& XSLT In order to copy/move a node from one XML::LibXML::Document to another, 
you need to call XML::LibXML::Document-> importNode( $node ) for copying 
or XML::LibXML::Document-> adoptNode( $node ) for moving before you can 
attach it to the new document tree.

For example, in your sample code you need to replace

$root-> appendChild( $results->getDocumentElement() );

with something along the lines of

my $import_node = $x-> importNode( $results->getDocumentElement() );
$root-> appendChild( $import_node );

HTH,
Richard

-----Original Message-----
From: Joshua Santelli <santellij@[...].com> 
To: perl-xml@[...].com
Sent: Mon, 21 Nov 2005 12:03:26 -0800 (PST)
Subject: LibXML, LibXSLT free(): invalid pointer error

  We're getting an "invalid pointer" error (see below)
from the following code.  Is there something that I am
doing wrong in either the XSLT or the perl code below?


I'm trying to track down a problem in a larger system
that we are developing and this small script appears
to reproduce that problem.

The LibXML, LibXSLT, perl and system versions are
below.

This is only a problem on Linux (spec below) and we
are not able to reproduce this problem on Solaris 9.

Thanks in advance.

=======================================
use XML::LibXSLT;
use XML::LibXML;

my $parser = XML::LibXML-> new();
my $xslt   = XML::LibXSLT-> new();
my $xml    = $ARGV[0];
my $xsl    = $ARGV[1];

my $x = XML::LibXML::Document-> new();
my $root = $x-> createElement("root");
$x-> setDocumentElement($root);

my $source     = $parser-> parse_file($xml);
my $style_doc  = $parser-> parse_file($xsl);
my $stylesheet = $xslt-> parse_stylesheet($style_doc);
my $results    = $stylesheet-> transform($source);

$root-> appendChild( $results->getDocumentElement() );

print $root-> serialize();
=======================================
# ./libxslt.pl 1.xml toc.xsl
<root> <test version="2.0">
  <foo/> 
*** glibc detected *** /usr/bin/perl: free(): invalid
pointer: 0x08780829 ***
======= Backtrace: =========
/lib/libc.so.6[0x84d424]
/lib/libc.so.6(__libc_free+0x77)[0x84d95f]
/usr/lib/libxml2.so.2(xmlFreeNodeList+0x146)[0x3ae382e]
/usr/lib/libxml2.so.2(xmlFreeNodeList+0x89)[0x3ae3771]
/usr/lib/libxml2.so.2(xmlFreeNodeList+0x89)[0x3ae3771]
/usr/lib/libxml2.so.2(xmlFreeDoc+0xdc)[0x3ae3e20]
  ... this goes on.
=======================================
<?xml version="1.0" encoding="UTF-8"?> 
<test version="2.0"> 
  <foo/> 
</test> 
=======================================
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
  <xsl:template match="/"> 
    <xsl:copy-of select="current()" /> 
  </xsl:template> 
</xsl:stylesheet> 
======================================
RedHat FC4
PERL v5.8.6 built for i386-linux-thread-multi

installed the following from source:
  XML::LibXSLT::VERSION ->  1.58
  libxslt version -> 1.1.15
  XML::LibXML::VERSION ->  1.58
  XML::LibXML::LIBXML_DOTTED_VERSION ->   2.6.22



__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

   
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Joshua Santelli
rrathmann
Joshua Santelli

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved