Bug #69363 [Nab]: eval()ed string literal is not interned on PHP7+OPcache
| From: | for-bugs at hnw dot jp | Date: | Fri, 03 Apr 2015 03:32:10 +0000 |
| Subject: | Bug #69363 [Nab]: eval()ed string literal is not interned on PHP7+OPcache | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191800@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69363&edit=1
ID: 69363
User updated by: for-bugs at hnw dot jp
Reported by: for-bugs at hnw dot jp
-Summary: eval()ed string literal is not intened on
PHP7+OPcache
+Summary: eval()ed string literal is not interned on
PHP7+OPcache
Status: Not a bug
Type: Bug
Package: opcache
Operating System: any
PHP Version: master-Git-2015-04-03 (Git)
Block user comment: N
Private report: N
New Comment:
Hmm. If you are right, enabling OPcache on PHP 7 causes little bit performance loss and consuming
more memories when we use eval().
$ php7 -d 'opcache.enable_cli=Off' /tmp/test-script.php
string(3) "baz" refcount(1)
string(3) "baz" refcount(1)
$ php7 -d 'opcache.enable_cli=On' /tmp/test-script.php
string(3) "baz" refcount(1)
string(3) "baz" refcount(2)
Previous Comments:
------------------------------------------------------------------------
[2015-04-03 02:39:56] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
first of all, use or not use interned string, should not be cared about user land, it's a
internal optimization, and also affects by intend string memory pool size .
and for opcache, opcache won't do any optimization for EVAL_CODES. so...this behavior is
expected.
thanks
------------------------------------------------------------------------
[2015-04-03 00:58:37] for-bugs at hnw dot jp
Description:
------------
On PHP7 without OPcache, eval('$bar="baz"') makes interned string. However,
eval()ed string literal is dynamically allocated with OPcache enabled.
The interned string on PHP7 is not refcounted. So, string refcount(2) means non-interned.
Test script:
---------------
<?php
$foo="baz";
$eval_str='$bar="baz";';
eval($eval_str);
debug_zval_dump($foo);
debug_zval_dump($bar);
Expected result:
----------------
string(3) "baz" refcount(1)
string(3) "baz" refcount(1)
Actual result:
--------------
string(3) "baz" refcount(1)
string(3) "baz" refcount(2)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69363&edit=1