From:             cunha17 at uol dot com dot br
Operating system: Redhat Linux 9/Fedora Core 1
PHP version:      5CVS-2004-05-06 (dev)
PHP Bug Type:     Reproducible crash
Bug description:  PHP5-rc2 coredumps with Smarty-2.6.2, error handler and exceptions

Description:
------------
First of all:
1. Using PHP-RC2 or PHP-CVS (2004-05-06)
2. Using Smarty-2.6.2 with customized tag(function)
3. Mapping PHP errors to exceptions(user error handler)

If there is an error inside the customized Smarty function, the error
handler routine raises an exception that doesn't reach any try/catch block
outside the Smarty class.

In fact, the exception doesn't propagate outside the fetch function in
file Smarty.class.php.

The exception is raised inside an "include" instruction and it's possible
to catch it inside the fetch function, but impossible anywhere else.

The fetch function is called from Smarty.class.php:1115 and the "include"
instruction is placed at Smarty.class.php:1266.

Cristiano Duarte

Reproduce code:
---------------
<?php
include('Smarty-2.6.2/libs/Smarty.class.php');
function smarty_test($params, $smarty)
{
        //Now we raise a notice about name not being defined
        //This should get mapped to an Exception
        return "{$params[name]}";
}
                                                                          
     
function my_error($nr, $text, $file, $line, $vars)
{
        $e = new Exception($text);
        throw $e;
}
error_reporting(E_ALL);
set_error_handler('my_error');
                                                                          
     
$s = new Smarty();
$s->register_function('test', 'smarty_test');
$s->display('exception_bug.tpl');
?>

Here is the template(exception_bug.tpl):
<html>
<head>
<title>Exception BUG</title>
</head>
<body>
{test name="ExceptionBugTest"}
</body>
</html>

Expected result:
----------------
Uncaught Exception 

Actual result:
--------------
Segmentation Fault (core dumped)

-- 
Edit bug report at http://bugs.php.net/?id=28306&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28306&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28306&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28306&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28306&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28306&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28306&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28306&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28306&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28306&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28306&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28306&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28306&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28306&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28306&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28306&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28306&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28306&r=float

Reply via email to