From: keithk at powderkeginteractive dot com Operating system: Linux PHP version: 5.5.0 Package: *General Issues Bug Type: Bug Bug description:Scanner Bug
Description: ------------ Environment: -Debian Linux Etch, Lenny, Squeeze and Wheezy (standard LAMP stacks) -Oracle Cluster File System (OCFS2) -PHP 5.3, 5.4 and 5.5 (across any of the above systems) PHP 5.3 and above seems to have an issue where the scanner scans past the end of a PHP script, allowing unexpected/junk characters to be tokenized and causing the parser to emit "unexpected ... at end of file" and related failures. This has happened across many different valid PHP scripts, so there isn't any "test script" I can reasonably provide. A common theme among the scripts, however, is that they end with } or some other single-token character. Note that this issue does *not* happen when using PHP 5.2 within the same environment and scripts. I suspect that memory mapping with a look-ahead buffer, as PHP/Zend does, isn't always returning the ideal case of null-padded data. This may be related to the specific use of OCFS2... perhaps one bug revealing another. At any rate, I've investigated the scanner and it does seem to make an assumption that supports the above edge case. The lex_scan function does not check if the buffer pointer is right at the limit, only before or after, allowing the scanner to read past the end of the buffer. Proposed solution: replace all instances of "(YYCURSOR > YYLIMIT)" with "(YYCURSOR >= YYLIMIT)" in Zend/zend_language_scanner.l -- Edit bug report at https://bugs.php.net/bug.php?id=65091&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65091&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65091&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65091&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65091&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65091&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65091&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65091&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65091&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65091&r=support Expected behavior: https://bugs.php.net/fix.php?id=65091&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65091&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65091&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65091&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65091&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65091&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65091&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65091&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65091&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65091&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65091&r=mysqlcfg