php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27236 xsl:key has bad memory cleanup
Submitted: 2004-02-12 19:55 UTC Modified: 2004-02-17 17:28 UTC
From: bo at theaddedones dot com Assigned:
Status: No Feedback Package: XSLT related
PHP Version: 4.3.4 OS: solaris 8, OSX 10.3, Redhat
Private report: No CVE-ID: None
 [2004-02-12 19:55 UTC] bo at theaddedones dot com
Description:
------------
i have a slew of xml data that i need to select unique values from ... the easiest method is via the xsl:key ... 

when i ever i use xsl:key to make a key (regardless of if i use or not) the xslt processor (libxml2 '20507', libxslt 1.0.30  -> 1.0.36 (the versions i have tried)) i get an 'xmlFree' error IF i compiled the libxml with the debug-mem option...if not i crashes the Apache (1.3.29) child  via a bus error...

the error....

Warning: Unknown(): Memory tag error occurs :0x6637671 bye in Unknown on line 0

Warning: Unknown(): xmlMemFree(6637691) error in Unknown on line 0

Warning: Unknown(): xmlMallocBreakpoint reached on block 0 in Unknown on line 0

interestingly, the entire XSL process works fine, and returns a properly converted document (even the keys work properly), it jsut dies with the memory error..i'm guessing something funny with garbage colleciton

Reproduce code:
---------------
the below should dump all the unique states in my data as a comma separated list

<xsl:key name="state_key" match="images" use="state"/>
<xsl:for-each
select="//data[generate-id()=generate-id(key('state_key',state)[1])]"><xsl:value-of select="state"/>, 
</xsl:for-each>

save as a normal xslt file
try to compile using dom ala 
domxml_xslt_stylesheet_file({your file})...
create some XML, and process the beast via 'process' you shall see the error

Expected result:
----------------
no silly memmory failures

Actual result:
--------------
Warning: Unknown(): Memory tag error occurs :0x6637671 bye in Unknown on line 0

Warning: Unknown(): xmlMemFree(6637691) error in Unknown on line 0

Warning: Unknown(): xmlMallocBreakpoint reached on block 0 in Unknown on line 0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-12 19:59 UTC] bo at theaddedones dot com
sorry, 
in the 'reporduce code' the proper xsl would be (just mistyped it)

<xsl:key name="state_key" match="data" use="state"/>
<xsl:for-each
select="//data[generate-id()=generate-id(key('state_key',state)[1])]"><xsl:value-of
select="state"/>, 
</xsl:for-each>
 [2004-02-13 12:08 UTC] bo at theaddedones dot com
here is compact code bit that seesms to give the error i speak of
----
<?php
$inSheet = 
'<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />

<xsl:key name="state_key" match="images" use="state"/>
<xsl:template name="TestKey">
	<xsl:for-each select="//images[generate-id()=generate-id(key(\'state_key\',state)[1])]">
		<xsl:value-of select="state"/>, 
	</xsl:for-each>
</xsl:template>
<xsl:template match="/" />
</xsl:stylesheet>';

$inXML = '<?xml version="1.0" encoding="ISO-8859-1"?>
	<images>
		<author>Karl Larsen</author>
		<city>Culver City</city>
		<state>CA</state>
		<country>USA</country>
	</images>';
$xsltString = domxml_xslt_stylesheet_doc(domxml_open_mem($inSheet));
$xmlString = domxml_open_mem($inXML);
$res = $xsltString->process($xmlString);
print $xsltString->result_dump_mem($res);
?>
 [2004-02-13 12:16 UTC] bo at theaddedones dot com
i should mention that the versions on the different systems  that the error seems to appear on the 

OSX 10.3 system is
php = 4.3.2 libxml = 20507, libxslt = 1.0.30

the verion on Solaris 8
php = 4.3.4, libxml = 20510, libxslt = 1.0.19

the version on Redhat 9
php 4.3.4, libxml = 20504, libxslt = 1.0.27
 [2004-02-13 12:27 UTC] bo at theaddedones dot com
As one more note
i tried using the normal 'xsltproc' command built from the same libs with the same inputs as the example and i get no error
 [2004-02-14 10:59 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Can not reproduce with latest stable CVS snapshot,
using these libxml/libxslt versions:

libxml Version => 20604
libxslt Version => 1.0.32

 [2004-02-17 17:28 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 17:01:31 2024 UTC