Re: [xml] xpath/xslt memory leak



Pawe³ Pa³ucha said:
Hi,
I think I've found a nice memory leak. I'm using xslt to reproduce it, but I
think that bug is in xpath module, so I send it here.

I don't think there is any such thing as a "nice" memory leak - leaks are bad,
bad, bad...

I'm working on the problem, but I'm not going to be able to continue for a few
days, so I thought I better reply in order to confirm your report.

The program is just transforming simple document in loop:

I can reproduce the leak using xsltproc, so there is no argument over whether
your program is good or bad.

<snip>

Document (b.xml) is like that:
<?xml version="1.0"?>
<params xmlns="http://www.praterm.com.pl/SZARP/ipk";>
     <param>
         <raport title="A"/>
     </param>
</params>

and stylesheet:

<?xml version="1.0"?>

                               <xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:ipk="http://www.praterm.com.pl/SZARP/ipk";>

                             <!-- <xsl:param name="title"/> -->
   <xsl:template match="ipk:params">
     <xsl:element name="report">
       <xsl:for-each select="//ipk:param[ipk:raport[ title=$title]]">
         <xsl:element name="param">
         </xsl:element>
       </xsl:for-each>
     </xsl:element>
   </xsl:template>
</xsl:stylesheet>

The stylesheet is somewhat incorrect - declaration of parameter 'title' is
missing. This simple program keeps allocating more and more memory (can be
viewed with top/htop). When I uncomment the parameter declaration, everything
works OK.

I simplified these documents a little - when debugging it's good to get rid of
all the non-esential parts (e.g. namespace isn't involved, etc.).  The missing
variable declaration is certainly a part of the problem.  Here's my reduced
set:

<?xml version="1.0"?>
<params><param/></params>

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:template match="params">
   <xsl:value-of select="param[ title=$title]"/>
 </xsl:template>
</xsl:stylesheet>

And, btw - the output from valgrind differs when I use
'--leak-resolution=high'.
Checked with 2.6.18, but there's nothing about it in changelog, so I suppose
its still there.

I'm just using
 valgrind --tool=memcheck --show-reachable=yes --leak-check=yes
--num-callers=15 xsltproc b.xsl b.xml

Problem is present in current CVS.
bill billsuper work $ xsltproc --version
Using libxml 20619-CVS2405, libxslt 10114-CVS1011 and libexslt 812-CVS1011

Files in attachment for convenience.

Pawe³ Pa³ucha

I'll respond further after I've had a chance to find / fix the problem (of
course, if someone else wants to do some debugging within xpath.c before I can
get back to it, they're certainly welcome to do so :-).  Thanks for the
report.

Bill




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]