Skip to content

Commit c6ce03e

Browse files
committed
Fixed bug #76205 (PHP-FPM sporadic crash when running Infinitewp).
1 parent 6738d19 commit c6ce03e

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ PHP NEWS
77
(mgorny)
88

99
- Opcache:
10+
. Fixed bug #76205 (PHP-FPM sporadic crash when running Infinitewp).
11+
(Dmitry)
1012
. Fixed bug #76275 (Assertion failure in file cache when unserializing empty
1113
try_catch_array). (Nikita)
1214
. Fixed bug #76281 (Opcache causes incorrect "undefined variable" errors).

ext/opcache/zend_file_cache.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,10 @@ static int zend_file_cache_flock(int fd, int type)
101101
#define IS_SERIALIZED(ptr) \
102102
((char*)(ptr) <= (char*)script->size)
103103
#define IS_UNSERIALIZED(ptr) \
104-
(((char*)(ptr) >= (char*)script->mem && (char*)(ptr) < (char*)script->mem + script->size) || \
105-
IS_ACCEL_INTERNED(ptr))
104+
((char*)(ptr) >= (char*)script->mem && (char*)(ptr) < (char*)script->mem + script->size)
106105
#define SERIALIZE_PTR(ptr) do { \
107106
if (ptr) { \
108-
ZEND_ASSERT(IS_UNSERIALIZED(ptr)); \
107+
ZEND_ASSERT(IS_UNSERIALIZED(ptr) || IS_ACCEL_INTERNED(ptr)); \
109108
(ptr) = (void*)((char*)(ptr) - (char*)script->mem); \
110109
} \
111110
} while (0)
@@ -952,12 +951,12 @@ static void zend_file_cache_unserialize_zval(zval *zv,
952951
switch (Z_TYPE_P(zv)) {
953952
case IS_STRING:
954953
case IS_CONSTANT:
955-
if (!IS_UNSERIALIZED(Z_STR_P(zv))) {
954+
if (IS_SERIALIZED(Z_STR_P(zv))) {
956955
UNSERIALIZE_STR(Z_STR_P(zv));
957956
}
958957
break;
959958
case IS_ARRAY:
960-
if (!IS_UNSERIALIZED(Z_ARR_P(zv))) {
959+
if (IS_SERIALIZED(Z_ARR_P(zv))) {
961960
HashTable *ht;
962961

963962
UNSERIALIZE_PTR(Z_ARR_P(zv));
@@ -967,7 +966,7 @@ static void zend_file_cache_unserialize_zval(zval *zv,
967966
}
968967
break;
969968
case IS_REFERENCE:
970-
if (!IS_UNSERIALIZED(Z_REF_P(zv))) {
969+
if (IS_SERIALIZED(Z_REF_P(zv))) {
971970
zend_reference *ref;
972971

973972
UNSERIALIZE_PTR(Z_REF_P(zv));
@@ -976,12 +975,12 @@ static void zend_file_cache_unserialize_zval(zval *zv,
976975
}
977976
break;
978977
case IS_CONSTANT_AST:
979-
if (!IS_UNSERIALIZED(Z_AST_P(zv))) {
978+
if (IS_SERIALIZED(Z_AST_P(zv))) {
980979
zend_ast_ref *ast;
981980

982981
UNSERIALIZE_PTR(Z_AST_P(zv));
983982
ast = Z_AST_P(zv);
984-
if (!IS_UNSERIALIZED(ast->ast)) {
983+
if (IS_SERIALIZED(ast->ast)) {
985984
ast->ast = zend_file_cache_unserialize_ast(ast->ast, script, buf);
986985
}
987986
}
@@ -993,7 +992,7 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
993992
zend_persistent_script *script,
994993
void *buf)
995994
{
996-
if (op_array->static_variables && !IS_UNSERIALIZED(op_array->static_variables)) {
995+
if (op_array->static_variables && IS_SERIALIZED(op_array->static_variables)) {
997996
HashTable *ht;
998997

999998
UNSERIALIZE_PTR(op_array->static_variables);
@@ -1018,7 +1017,7 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
10181017
return;
10191018
}
10201019

1021-
if (op_array->literals && !IS_UNSERIALIZED(op_array->literals)) {
1020+
if (op_array->literals && IS_SERIALIZED(op_array->literals)) {
10221021
zval *p, *end;
10231022

10241023
UNSERIALIZE_PTR(op_array->literals);
@@ -1030,7 +1029,7 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
10301029
}
10311030
}
10321031

1033-
if (!IS_UNSERIALIZED(op_array->opcodes)) {
1032+
if (IS_SERIALIZED(op_array->opcodes)) {
10341033
zend_op *opline, *end;
10351034

10361035
UNSERIALIZE_PTR(op_array->opcodes);
@@ -1089,10 +1088,10 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
10891088
end++;
10901089
}
10911090
while (p < end) {
1092-
if (!IS_UNSERIALIZED(p->name)) {
1091+
if (IS_SERIALIZED(p->name)) {
10931092
UNSERIALIZE_STR(p->name);
10941093
}
1095-
if (!IS_UNSERIALIZED(p->class_name)) {
1094+
if (IS_SERIALIZED(p->class_name)) {
10961095
UNSERIALIZE_STR(p->class_name);
10971096
}
10981097
p++;
@@ -1106,7 +1105,7 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
11061105
p = op_array->vars;
11071106
end = p + op_array->last_var;
11081107
while (p < end) {
1109-
if (!IS_UNSERIALIZED(*p)) {
1108+
if (IS_SERIALIZED(*p)) {
11101109
UNSERIALIZE_STR(*p);
11111110
}
11121111
p++;
@@ -1138,19 +1137,19 @@ static void zend_file_cache_unserialize_prop_info(zval *zv,
11381137
zend_persistent_script *script,
11391138
void *buf)
11401139
{
1141-
if (!IS_UNSERIALIZED(Z_PTR_P(zv))) {
1140+
if (IS_SERIALIZED(Z_PTR_P(zv))) {
11421141
zend_property_info *prop;
11431142

11441143
UNSERIALIZE_PTR(Z_PTR_P(zv));
11451144
prop = Z_PTR_P(zv);
11461145

1147-
if (prop->ce && !IS_UNSERIALIZED(prop->ce)) {
1146+
if (prop->ce && IS_SERIALIZED(prop->ce)) {
11481147
UNSERIALIZE_PTR(prop->ce);
11491148
}
1150-
if (prop->name && !IS_UNSERIALIZED(prop->name)) {
1149+
if (prop->name && IS_SERIALIZED(prop->name)) {
11511150
UNSERIALIZE_STR(prop->name);
11521151
}
1153-
if (prop->doc_comment && !IS_UNSERIALIZED(prop->doc_comment)) {
1152+
if (prop->doc_comment && IS_SERIALIZED(prop->doc_comment)) {
11541153
UNSERIALIZE_STR(prop->doc_comment);
11551154
}
11561155
}
@@ -1160,17 +1159,17 @@ static void zend_file_cache_unserialize_class_constant(zval *
11601159
zend_persistent_script *script,
11611160
void *buf)
11621161
{
1163-
if (!IS_UNSERIALIZED(Z_PTR_P(zv))) {
1162+
if (IS_SERIALIZED(Z_PTR_P(zv))) {
11641163
zend_class_constant *c;
11651164

11661165
UNSERIALIZE_PTR(Z_PTR_P(zv));
11671166
c = Z_PTR_P(zv);
11681167

11691168
zend_file_cache_unserialize_zval(&c->value, script, buf);
1170-
if (c->ce && !IS_UNSERIALIZED(c->ce)) {
1169+
if (c->ce && IS_SERIALIZED(c->ce)) {
11711170
UNSERIALIZE_PTR(c->ce);
11721171
}
1173-
if (c->doc_comment && !IS_UNSERIALIZED(c->doc_comment)) {
1172+
if (c->doc_comment && IS_SERIALIZED(c->doc_comment)) {
11741173
UNSERIALIZE_STR(c->doc_comment);
11751174
}
11761175
}

0 commit comments

Comments
 (0)