Bug #76477 [Com]: Opcache causes empty return value

From: Date: Tue, 18 Sep 2018 11:43:02 +0000
Subject: Bug #76477 [Com]: Opcache causes empty return value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217108@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76477&edit=1 ID: 76477 Comment by: mark2011 at mayberg dot se Reported by: mark2011 at mayberg dot se Summary: Opcache causes empty return value Status: Closed Type: Bug Package: opcache Operating System: Linux PHP Version: 7.2.6 Block user comment: N Private report: N New Comment: PHP 7.2.10 is now available for my distro and includes the bugfix. I can confirm that this issue has been solved, Thank you. Previous Comments: ------------------------------------------------------------------------ [2018-06-15 08:32:39] laruence@php.net Automatic comment on behalf of laruence@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=f31ba7cb53271f6745c5efb1b15c53ffd5cb4b6e Log: Fixed bug #76477 (Opcache causes empty return value) ------------------------------------------------------------------------ [2018-06-14 14:52:10] nikic@php.net This is a type-inference bug: strlenb: ; (lines=5, args=0, vars=0, tmps=1, ssa_vars=2, no_loops) ; (after dfa pass) ; /home/nikic/php-7.2/t001.php:10-10 ; return [null] BB0: start exit lines=[0-4] ; level=0 INIT_FCALL 0 80 string("strlen") #0.T0 [array [long] of [any]] = FUNC_GET_ARGS SEND_ARRAY 0 #0.T0 [array [long] of [any]] #1.V0 [null] = DO_FCALL RETURN #1.V0 [null] The return value of strlen() is determined to be null, which is wrong. The type is determined by zend_strlen_info(), which doesn't take the SEND_ARRAY into account properly. The same issue might also affect other custom inference functions. Btw, this particular one we can really just drop, because all useful cases are already handled by ZEND_STRLEN. ------------------------------------------------------------------------ [2018-06-14 14:37:03] cmb@php.net I can confirm that this issue affects PHP-7.2 and master, but not PHP-7.1 (older version are not actively supported anymore). ------------------------------------------------------------------------ [2018-06-14 14:21:14] sjon at hortensius dot net I can reproduce this with a pretty vanilla 7.2.6 under Archlinux. It can be simplified somewhat; this is also unstable (sometimes it returns 3, sometimes NULL): <?php t(); function t() { $l = strlenb("ABC"); var_dump($l); } function strlenb() { return call_user_func_array("strlen", func_get_args()); } ------------------------------------------------------------------------ [2018-06-14 13:16:51] mark2011 at mayberg dot se Description: ------------ Running the test script without opcache works fine. But with opcache enabled it results in an unexpected behaviour (after second execution). The test script below is extracted from a bigger library, I isolated a small test case. PHP 7.2.6 is not yet available for my distro. PHP 7.0, 7.1 does not show this error. Test script: --------------- <?php echo "PHP ".PHP_VERSION." ".PHP_SAPI."<br>\n"; $token = "ABC"; $lengthBytes = strlenb($token); echo "$token $lengthBytes ".($lengthBytes!=0 ? "ok" : "error")."<br>\n"; testString(); function testString() { $token = "ABC"; $lengthBytes = strlenb($token); echo "$token $lengthBytes ".($lengthBytes!=0 ? "ok" : "error")."<br>\n"; } function strlenb() { return call_user_func_array("strlen", func_get_args()); } ?> Expected result: ---------------- PHP 7.2.5-0ubuntu0.18.04.1 apache2handler ABC 3 ok ABC 3 ok Actual result: -------------- PHP 7.2.5-0ubuntu0.18.04.1 apache2handler ABC 3 ok ABC error ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76477&edit=1

« previous php.bugs (#217108) next »