diff --git a/NEWS b/NEWS index 865689886a4..a4804cb34f7 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,10 @@ PHP NEWS . Fixed bug #81346 (Non-seekable streams don't update position after write). (cmb) +- Opcache: + . Fixed bug #81353 (segfault with preloading and statically bound closure). + (Nikita) + - XML: . Fixed bug #81351 (xml_parse may fail, but has no error code). (cmb, Nikita) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 73be3509143..6dd109e6c3a 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -4599,6 +4599,20 @@ static int accel_preload(const char *config, zend_bool in_child) } } ZEND_HASH_FOREACH_END(); + if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) { + zval_ptr_dtor(&EG(user_error_handler)); + ZVAL_UNDEF(&EG(user_error_handler)); + } + + if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) { + zval_ptr_dtor(&EG(user_exception_handler)); + ZVAL_UNDEF(&EG(user_exception_handler)); + } + + zend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1); + zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1); + zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1); + CG(map_ptr_last) = orig_map_ptr_last; if (EG(full_tables_cleanup)) { diff --git a/ext/opcache/tests/preload_error_handler.inc b/ext/opcache/tests/preload_error_handler.inc new file mode 100644 index 00000000000..ab2204ceaa1 --- /dev/null +++ b/ext/opcache/tests/preload_error_handler.inc @@ -0,0 +1,8 @@ + +--FILE-- +===DONE=== +--EXPECTF-- +Warning: Can't preload unlinked class B: Unknown parent A in %s on line %d +===DONE=== diff --git a/ext/opcache/tests/preload_error_handler_ind.inc b/ext/opcache/tests/preload_error_handler_ind.inc new file mode 100644 index 00000000000..d493d572a08 --- /dev/null +++ b/ext/opcache/tests/preload_error_handler_ind.inc @@ -0,0 +1,4 @@ +