Skip to content

Commit 86d470f

Browse files
committed
Reset CE cache slots on opcache reset
Permanent opcache interned strings could have ce_cache pointing to non-permanent map_ptr slots. On reset, those would be left dangling. Clear any non-permanent ce_cache slots when the interned string state is reset. This was fun to debug...
1 parent b364644 commit 86d470f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,15 @@ static void accel_interned_strings_restore_state(void)
411411
n = 0;
412412
if (EXPECTED(s < top)) {
413413
do {
414+
if (ZSTR_HAS_CE_CACHE(s)) {
415+
/* Discard non-global CE_CACHE slots on reset. */
416+
uintptr_t idx = (GC_REFCOUNT(s) - 1) / sizeof(void *);
417+
if (idx >= ZCSG(map_ptr_last)) {
418+
GC_SET_REFCOUNT(s, 2);
419+
GC_DEL_FLAGS(s, IS_STR_CLASS_NAME_MAP_PTR);
420+
}
421+
}
422+
414423
hash_slot = STRTAB_HASH_TO_SLOT(&ZCSG(interned_strings), ZSTR_H(s));
415424
STRTAB_COLLISION(s) = *hash_slot;
416425
*hash_slot = STRTAB_STR_TO_POS(&ZCSG(interned_strings), s);

0 commit comments

Comments
 (0)