Bug #80523 [Com]: bogus parse error on >4GB source code

From: Date: Wed, 16 Dec 2020 09:29:25 +0000
Subject: Bug #80523 [Com]: bogus parse error on >4GB source code
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231114@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80523&edit=1 ID: 80523 Comment by: divinity76 at gmail dot com Reported by: divinity76 at gmail dot com Summary: bogus parse error on >4GB source code Status: Closed Type: Bug Package: Reproducible crash PHP Version: 7.4.13 Block user comment: N Private report: N New Comment: nikic@php.net you said you get OOM killed before being able to test it? on how much ram? i have a 64GB ram system to test on, and a 128GB ram system is on the way (should be ready in a couple of days) Previous Comments: ------------------------------------------------------------------------ [2020-12-16 09:21:14] nikic@php.net Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=118ff03335d67c19817ff83d89e634fcd39275ff Log: Fix bug #80523 ------------------------------------------------------------------------ [2020-12-16 03:22:15] divinity76 at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=80523&edit=1

« previous php.bugs (#231114) next »