ID: 30772
Updated by: [EMAIL PROTECTED]
Reported By: pecoes at web dot de
-Status: Open
+Status: Analyzed
Bug Type: Reproducible crash
-Operating System: windows xp
+Operating System: irrelevant
-PHP Version: 5.0.2
+PHP Version: 5.0.2, 5.1
-Assigned To:
+Assigned To: andi
New Comment:
Reproducible both with 5.0 & 5.1 branches.
Program received signal SIGSEGV, Segmentation fault.
0x00000006 in ?? ()
(gdb) bt
#0 0x00000006 in ?? ()
#1 0x00000000 in ?? ()
#2 0xbfffbf30 in ?? ()
#3 0xbfffbf68 in ?? ()
#4 0xbfffbeec in ?? ()
#5 0x00000001 in ?? ()
#6 0x08226ebb in yy_chk ()
#7 0xbfffbf68 in ?? ()
#8 0x08188964 in zif_class_exists (ht=-1073758484, return_value=0x1,
this_ptr=0x8226ebb, return_value_used=-1073758360)
at /home/dev/php-src/Zend/zend_builtin_functions.c:907
Previous frame inner to this frame (corrupt stack?)
Reproduce code could be safely reduced to this:
<?
function __autoload ($class) {
require_once "$class.php";
}
php_check_syntax("Test.php");
class_exists("Test");
?>
Previous Comments:
------------------------------------------------------------------------
[2004-11-13 10:24:20] pecoes at web dot de
Description:
------------
The reproduce code is pretty straight-forward, which makes the issue
look easy to avoid. My real problem, however, is more subtle:
I'm writing an extensible library. All my internal classes are
__autoload'ed, but I want to treat all user-defined classes as tainted
and load them manually:
Test.php:
<?php
class Tets {} // Note the typo!
?>
bug.php:
<?php
function __autoload ($class) {
require_once "$class.php";
}
function loadManually ($class) {
if (!php_check_syntax("$class.php")) {
throw new Exception("$class.php cannot be included");
}
// class_exists invokes __autoload and things go wrong
if (!class_exists($class)) {
throw new Exception("$class does not exist in $class.php");
}
}
loadManually("Test");
?>
Reproduce code:
---------------
$file = "Test.php";
if (!php_check_syntax($file)) {
die("$file cannot be included");
}
// the following line should do nothing!
require_once $file;
Expected result:
----------------
no crash
Actual result:
--------------
"Fatal Error: Cannot redeclare class..."
and then php(cli) crashes hard!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30772&edit=1