Skip to content

Commit 3291891

Browse files
committed
Fixed bug #79128
We need to extend the hash table before performing raw append operations. This doesn't matter if preloading happens in the same process, as the tables will be large enough to hold all entries as a side-effect of the preloading process. However, if preloading happens in a different process, we need to reserve space here.
1 parent c14df82 commit 3291891

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ PHP NEWS
2929
with more than 20 chars). (Nikita)
3030

3131
- Opcache:
32-
. Fixed #79114 (Eval class during preload causes class to be only half
32+
. Fixed bug #79114 (Eval class during preload causes class to be only half
3333
available). (Laruence)
34+
. Fixed bug #79128 (Preloading segfaults if preload_user is used). (Nikita)
3435

3536
- OpenSSL:
3637
. Fixed bug #79145 (openssl memory leak). (cmb, Nikita)

ext/opcache/ZendAccelerator.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4200,19 +4200,24 @@ static zend_persistent_script* preload_script_in_shared_memory(zend_persistent_s
42004200
static void preload_load(void)
42014201
{
42024202
/* Load into process tables */
4203-
if (zend_hash_num_elements(&ZCSG(preload_script)->script.function_table)) {
4204-
Bucket *p = ZCSG(preload_script)->script.function_table.arData;
4205-
Bucket *end = p + ZCSG(preload_script)->script.function_table.nNumUsed;
4203+
zend_script *script = &ZCSG(preload_script)->script;
4204+
if (zend_hash_num_elements(&script->function_table)) {
4205+
Bucket *p = script->function_table.arData;
4206+
Bucket *end = p + script->function_table.nNumUsed;
42064207

4208+
zend_hash_extend(CG(function_table),
4209+
CG(function_table)->nNumUsed + script->function_table.nNumUsed, 0);
42074210
for (; p != end; p++) {
42084211
_zend_hash_append_ptr_ex(CG(function_table), p->key, Z_PTR(p->val), 1);
42094212
}
42104213
}
42114214

4212-
if (zend_hash_num_elements(&ZCSG(preload_script)->script.class_table)) {
4213-
Bucket *p = ZCSG(preload_script)->script.class_table.arData;
4214-
Bucket *end = p + ZCSG(preload_script)->script.class_table.nNumUsed;
4215+
if (zend_hash_num_elements(&script->class_table)) {
4216+
Bucket *p = script->class_table.arData;
4217+
Bucket *end = p + script->class_table.nNumUsed;
42154218

4219+
zend_hash_extend(CG(class_table),
4220+
CG(class_table)->nNumUsed + script->class_table.nNumUsed, 0);
42164221
for (; p != end; p++) {
42174222
_zend_hash_append_ex(CG(class_table), p->key, &p->val, 1);
42184223
}

0 commit comments

Comments
 (0)