Bug #80523 [NEW]: bogus parse error on >4GB source code
| From: | divinity76 at gmail dot com | Date: | Wed, 16 Dec 2020 03:22:15 +0000 |
| Subject: | Bug #80523 [NEW]: bogus parse error on >4GB source code | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-231110@lists.php.net to get a copy of this message | ||
From: divinity76 at gmail dot com
Operating system:
PHP version: 7.4.13
Package: Reproducible crash
Bug Type: Bug
Bug description:bogus parse error on >4GB source code
Description:
------------
it appears that PHP crash when trying to parse source code above 4GB in
size,
notably the code below is not a syntax error if you change it to
$imax = (int)((1*1024*1024*1024)/strlen("'hello',"));
but if you just change the 1* to 4*, it's suddenly a "syntax error",
PS: don't recommend trying this on a system with less than 20GB ram,
htop reported over 18GB ram while running..
Test script:
---------------
<?php
$str='<?php return array(';
$imax = (int)((4*1024*1024*1024)/strlen("'hello',"));
echo "generating..";
$str.=str_repeat("'hello',",$imax);
$str.=");";
echo "generated. writing.";
file_put_contents("wtf.php",$str);
echo "written. gcing";
unset($str);gc_collect_cycles(); // << dunno if that actually helps
echo ". done. including.";
require("wtf.php");
Expected result:
----------------
no syntax error
Actual result:
--------------
root@x2ratma:/temp/fag# time php fag.php
generating..generated. writing.written. gcing. done. including.PHP Parse
error: syntax error, unexpected ''h' (T_ENCAPSED_AND_WHITESPACE),
expecting ')' in /temp/fag/wtf.php on line 1
real 0m24.960s
user 0m4.927s
sys 0m17.147s
root@x2ratma:/temp/fag#
--
Edit bug report at https://bugs.php.net/bug.php?id=80523&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80523&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80523&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80523&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80523&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80523&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80523&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80523&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80523&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80523&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80523&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80523&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80523&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80523&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80523&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80523&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80523&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80523&r=mysqlcfg