php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29573 Segmentation fault when php function(called from XSLT templat) throw exception
Submitted: 2004-08-08 18:08 UTC Modified: 2004-08-08 20:09 UTC
From: x-penguin at tut dot by Assigned:
Status: Closed Package: XSLT related
PHP Version: 5CVS-2004-08-08 (dev) OS: Linux
Private report: No CVE-ID:
 [2004-08-08 18:08 UTC] x-penguin at tut dot by
Description:
------------
Child httpd process segfault, when php function(called from XSLT template) throw exception, and when exception was throwed from steream wrapper, used in XSLT template.

PHP Version 5.1.0-dev, configure with:
'./configure' '--prefix=/usr/' '--with-apxs2' '--with-gettext' '--with-iconv' '--with-mysql' '--enable-mbstring=ru' '--enable-mbregex' '--enable-mbstr-enc-trans' '--disable-short-tags' '--with-xsl' '--with-libxml' '--without-sqlite' '--enable-soap'

libxslt Version 	1.1.8
libxml Version 	2.6.11
libexslt Version 	1.1.8

apache 2.0.48

Reproduce code:
---------------
<?php
try {
    function throwFunction() {
        throw new Exception('exception messaage');
    }
    
    $xsl = new DomDocument();
    $xsl->loadXML(
    '<?xml version="1.0" encoding="iso-8859-1" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
    <xsl:template match="/">
    <xsl:value-of select="php:function(\'throwFunction\')" />
    </xsl:template>
    </xsl:stylesheet>'
    );
    
    $xml = new DomDocument;
    $xml->loadXML(
    '<?xml version="1.0" encoding="iso-8859-1" ?>
    <null></null>'
    );
    
    $proc = new XSLTProcessor();
    $proc->registerPhpFunctions();
    $proc->importStylesheet($xsl);
    
    $dom = $proc->transformToDoc($xml);
} catch(Exception $exception) {
    echo $exception;
}
?>

Expected result:
----------------
exception 'Exception' with message 'exception messaage' in /mnt/data/www/html/web/test.php:4
Stack trace:
#0 /mnt/data/www/html/web/test.php(27): XSLTProcessor->throwFunction()
#1 /mnt/data/www/html/web/test.php(27): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}

Actual result:
--------------
from apache error log:
[Sun Aug 08 18:55:33 2004] [notice] child pid 1337 exit signal Segmentation fault (11)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-08 18:59 UTC] chregu@php.net
That's not supposed to work this way ;)

I'm not sure, if we can pass exceptions from php function called within XSLT back to the PHP script starting the transformation (we have libxml2 twice in the middle of that, that's the problem).

But of course, it shouldn't segfault and that's fixable. Expect a patch for that soon




 [2004-08-08 20:09 UTC] chregu@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in PHP_5_0 branch as well.

And, surprisingly, the exceptions bubbles up to the calling transformation function... Everything should now work as expected.

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 01:01:56 2014 UTC