Skip to content

Commit db0cdcb

Browse files
committed
Fix static property indirections in file cache
If the class is already linked, we need to serialize and unserialize INDIRECTed static properties. Normally these would be set up when copying from cache.
1 parent 8819d24 commit db0cdcb

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

ext/opcache/zend_file_cache.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ static void zend_file_cache_serialize_zval(zval *zv,
368368
zend_file_cache_serialize_ast(GC_AST(ast), script, info, buf);
369369
}
370370
break;
371+
case IS_INDIRECT:
372+
/* Used by static properties. */
373+
SERIALIZE_PTR(Z_INDIRECT_P(zv));
374+
break;
371375
}
372376
}
373377

@@ -626,7 +630,6 @@ static void zend_file_cache_serialize_class(zval *zv,
626630
void *buf)
627631
{
628632
zend_class_entry *ce;
629-
zend_class_entry *parent = NULL;
630633

631634
SERIALIZE_PTR(Z_PTR_P(zv));
632635
ce = Z_PTR_P(zv);
@@ -637,7 +640,6 @@ static void zend_file_cache_serialize_class(zval *zv,
637640
if (!(ce->ce_flags & ZEND_ACC_LINKED)) {
638641
SERIALIZE_STR(ce->parent_name);
639642
} else {
640-
parent = ce->parent;
641643
SERIALIZE_PTR(ce->parent);
642644
}
643645
}
@@ -655,16 +657,13 @@ static void zend_file_cache_serialize_class(zval *zv,
655657
}
656658
}
657659
if (ce->default_static_members_table) {
658-
zval *table, *p, *end;
660+
zval *p, *end;
659661

660662
SERIALIZE_PTR(ce->default_static_members_table);
661-
table = ce->default_static_members_table;
662-
UNSERIALIZE_PTR(table);
663+
p = ce->default_static_members_table;
664+
UNSERIALIZE_PTR(p);
663665

664-
/* Serialize only static properties in this class.
665-
* Static properties from parent classes will be handled in class_copy_ctor */
666-
p = table + (parent ? parent->default_static_members_count : 0);
667-
end = table + ce->default_static_members_count;
666+
end = p + ce->default_static_members_count;
668667
while (p < end) {
669668
zend_file_cache_serialize_zval(p, script, info, buf);
670669
p++;
@@ -1081,6 +1080,10 @@ static void zend_file_cache_unserialize_zval(zval *zv,
10811080
zend_file_cache_unserialize_ast(Z_ASTVAL_P(zv), script, buf);
10821081
}
10831082
break;
1083+
case IS_INDIRECT:
1084+
/* Used by static properties. */
1085+
UNSERIALIZE_PTR(Z_INDIRECT_P(zv));
1086+
break;
10841087
}
10851088
}
10861089

@@ -1325,7 +1328,6 @@ static void zend_file_cache_unserialize_class(zval *zv,
13251328
void *buf)
13261329
{
13271330
zend_class_entry *ce;
1328-
zend_class_entry *parent = NULL;
13291331

13301332
UNSERIALIZE_PTR(Z_PTR_P(zv));
13311333
ce = Z_PTR_P(zv);
@@ -1336,7 +1338,6 @@ static void zend_file_cache_unserialize_class(zval *zv,
13361338
UNSERIALIZE_STR(ce->parent_name);
13371339
} else {
13381340
UNSERIALIZE_PTR(ce->parent);
1339-
parent = ce->parent;
13401341
}
13411342
}
13421343
zend_file_cache_unserialize_hash(&ce->function_table,
@@ -1353,14 +1354,10 @@ static void zend_file_cache_unserialize_class(zval *zv,
13531354
}
13541355
}
13551356
if (ce->default_static_members_table) {
1356-
zval *table, *p, *end;
1357-
1358-
/* Unserialize only static properties in this class.
1359-
* Static properties from parent classes will be handled in class_copy_ctor */
1357+
zval *p, *end;
13601358
UNSERIALIZE_PTR(ce->default_static_members_table);
1361-
table = ce->default_static_members_table;
1362-
p = table + (parent ? parent->default_static_members_count : 0);
1363-
end = table + ce->default_static_members_count;
1359+
p = ce->default_static_members_table;
1360+
end = p + ce->default_static_members_count;
13641361
while (p < end) {
13651362
zend_file_cache_unserialize_zval(p, script, buf);
13661363
p++;

0 commit comments

Comments
 (0)