diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index f9514d4807c4e..a81dbee97ee59 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2428,9 +2428,22 @@ static zend_class_entry* zend_accel_inheritance_cache_add(zend_class_entry *ce, } ZEND_HASH_FOREACH_END(); ZCG(mem) = (char*)ZCG(mem) + zend_hash_num_elements(dependencies) * sizeof(zend_class_dependency); } + + /* See GH-15657: `zend_persist_class_entry` can JIT property hook code via + * `zend_persist_property_info`, but the inheritance cache should not + * JIT those at this point in time. */ +#ifdef HAVE_JIT + bool jit_on_old = JIT_G(on); + JIT_G(on) = false; +#endif + entry->ce = new_ce = zend_persist_class_entry(ce); zend_update_parent_ce(new_ce); +#ifdef HAVE_JIT + JIT_G(on) = jit_on_old; +#endif + entry->num_warnings = EG(num_errors); entry->warnings = zend_persist_warnings(EG(num_errors), EG(errors)); entry->next = proto->inheritance_cache; diff --git a/ext/opcache/tests/jit/gh15657.phpt b/ext/opcache/tests/jit/gh15657.phpt new file mode 100644 index 0000000000000..4fc35d3b5bd00 --- /dev/null +++ b/ext/opcache/tests/jit/gh15657.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-15657 (Segmentation fault in ext/opcache/jit/ir/dynasm/dasm_x86.h) +--EXTENSIONS-- +opcache +--INI-- +opcache.jit_buffer_size=64M +opcache.jit=1101 +--FILE-- + $this->_prop; + } +} +echo "Done\n"; +?> +--EXPECT-- +Done