From:             pecoes at web dot de
Operating system: windows xp
PHP version:      5.0.2
PHP Bug Type:     Reproducible crash
Bug description:  php_check_syntax collides with require_once

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

Reply via email to