diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 06e171b179b..22b484b7894 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2634,7 +2634,9 @@ static int zend_accel_init_shm(void) if (ZCG(accel_directives).interned_strings_buffer) { accel_shared_globals = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024)); } else { - accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals)); + /* Make sure there is always at least one interned string hash slot, + * so the table can be queried unconditionally. */ + accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals) + sizeof(uint32_t)); } if (!accel_shared_globals) { zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); @@ -2675,6 +2677,8 @@ static int zend_accel_init_shm(void) STRTAB_INVALID_POS, (char*)ZCSG(interned_strings).start - ((char*)&ZCSG(interned_strings) + sizeof(zend_string_table))); + } else { + *STRTAB_HASH_TO_SLOT(&ZCSG(interned_strings), 0) = STRTAB_INVALID_POS; } zend_interned_strings_set_request_storage_handlers(accel_new_interned_string_for_php, accel_init_interned_string_for_php);