Bug #73606 [Fbk->NoF]: accel_find_interned_string not have read lock
| From: | php-bugs at lists dot php dot net | Date: | Sun, 01 Aug 2021 04:22:14 +0000 |
| Subject: | Bug #73606 [Fbk->NoF]: accel_find_interned_string not have read lock | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235503@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73606&edit=1
ID: 73606
Updated by: php-bugs@lists.php.net
Reported by: 804368954 at qq dot com
Summary: accel_find_interned_string not have read lock
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: opcache
Operating System: CentOS Linux release 6.2 (Final)
PHP Version: 7.0Git-2016-11-25 (Git)
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2021-07-23 08:04:42] nikic@php.net
Does this problem still manifest on a supported version of PHP?
Generally, reads from opcache SHM always happen without a separate lock. We only track how many SHM
users there are. When opcache_reset() is called, the cache is not immediately reset, but only a
restart is scheduled. The actual cache reset will only happen once all current SHM users have
detached from the cache. At that point nobody should be reading the cache, and it's safe to
reset it. For that reason no fine-grained read locking is necessary.
------------------------------------------------------------------------
[2016-11-25 11:09:53] 804368954 at qq dot com
Description:
------------
when exec "opcache_reset()" by cacheTool, We offen get Fatal errorï¼[25-Nov-2016
14:07:07 Asia/Shanghai] PHP Fatal error: Unknown: Failed opening required
'/home/xxxx/index.php' (include_path='.:/home/php7/lib/php') in Unknown on line
0(just on error log,not warning), then I check ZendAccelerator.c, find this code:
static zend_string *accel_find_interned_string(zend_string *str)
{
/* for now interned strings are supported only for non-ZTS build */
zend_ulong h;
uint nIndex;
uint idx;
Bucket *arData, *p;
if (IS_ACCEL_INTERNED(str)) {
/* this is already an interned string */
return str;
}
if (!ZCG(counted)) {
if (accel_activate_add() == FAILURE) {
return str;
}
ZCG(counted) = 1;
}
h = zend_string_hash_val(str);
nIndex = h | ZCSG(interned_strings).nTableMask;
/* check for existing interned string */
idx = HT_HASH(&ZCSG(interned_strings), nIndex);
arData = ZCSG(interned_strings).arData;
while (idx != HT_INVALID_IDX) {
p = HT_HASH_TO_BUCKET_EX(arData, idx);
if ((p->h == h) && (ZSTR_LEN(p->key) == ZSTR_LEN(str))) {
if (!memcmp(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str))) {
return p->key;
}
}
idx = Z_NEXT(p->val);
}
return NULL;
}
it read shared memory, but I don't find read lock in function, because
"opcache_rerest()" will execute "accel_interned_strings_restore_state()"
function, it will write shared memory. I'm not an expert, so need your help,thanks!
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73606&edit=1