Bug #66337 [Asn->Nab]: Wrong size calculation on optimization of class constants
| From: | dmitry@php.net | Date: | Mon, 23 Dec 2013 16:46:53 +0000 |
| Subject: | Bug #66337 [Asn->Nab]: Wrong size calculation on optimization of class constants | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-183452@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66337&edit=1
ID: 66337
Updated by: dmitry@php.net
Reported by: Terry at ellisons dot org dot uk
Summary: Wrong size calculation on optimization of class
constants
-Status: Assigned
+Status: Not a bug
Type: Bug
Package: opcache
Operating System: N/A
PHP Version: master-Git-2013-12-22 (Git)
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
It seems like it's a false alarm or the bug is already fixed.
Previous Comments:
------------------------------------------------------------------------
[2013-12-23 16:32:44] Terry at ellisons dot org dot uk
Sorry my bad. You can close this one: the test works, now that I've synced my dev config to
current PHP-5.6. One of the updates to 5.6 in the last few has already fixed this.
------------------------------------------------------------------------
[2013-12-23 13:12:31] Terry at ellisons dot org dot uk
OK, I'll refresh my dev snapshot from GiT -- it's a week out of date. This might have
been separately fixed by Xinchen. If so it's a pity because it took quite a few hours to locate
the exact failure :-( Let me examine and post back.
------------------------------------------------------------------------
[2013-12-23 12:23:20] dmitry@php.net
In my opinion optimizer shouldn't create interned strings.
------------------------------------------------------------------------
[2013-12-23 12:22:19] dmitry@php.net
I can't reproduce this.
In my opinion
------------------------------------------------------------------------
[2013-12-22 23:42:02] Terry at ellisons dot org dot uk
OK, the peephole optimizer for references to string class constants replaces the instruction
sequence:
FETCH_CONSTANT ~n 'SomeClass', 'CONSTANT'
ASSIGN !n, ~m
with
ASSIGN !0, Interned_string(Value of SomeClass::CONSTANT)
The while loop at zend_persist.c:263 calls zend_persist_zval() which is effectively a NOOP for
existing interned strings.
On the otherhand the corresponding loop at zend_persist_calc.c:172 calls zend_persist_zval_calc() to
compute the size of the literal string. This invokes the ADD_INTERNED_STRING() macro at
zend_persist_calc.c:118.
However this logic is flawed is the string is ALREADY interned and it therefore incorrectly adds the
size of the string to the computed size. This triggers the subsequent "Wrong size
calculation" warning.
I won't include the obvious fix here because I suspect that this exposes a couple of separate
but related bugs which I want to explore and raise in their own bugreps.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=66337
--
Edit this bug report at https://bugs.php.net/bug.php?id=66337&edit=1