Skip to content

Commit 47ccdec

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fixed bug #81353
2 parents 15e5cf8 + d1e956f commit 47ccdec

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ PHP NEWS
77
. Fixed bug #81346 (Non-seekable streams don't update position after write).
88
(cmb)
99

10+
- Opcache:
11+
. Fixed bug #81353 (segfault with preloading and statically bound closure).
12+
(Nikita)
13+
1014
- XML:
1115
. Fixed bug #81351 (xml_parse may fail, but has no error code). (cmb, Nikita)
1216

ext/opcache/ZendAccelerator.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,6 +4599,20 @@ static int accel_preload(const char *config, zend_bool in_child)
45994599
}
46004600
} ZEND_HASH_FOREACH_END();
46014601

4602+
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
4603+
zval_ptr_dtor(&EG(user_error_handler));
4604+
ZVAL_UNDEF(&EG(user_error_handler));
4605+
}
4606+
4607+
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
4608+
zval_ptr_dtor(&EG(user_exception_handler));
4609+
ZVAL_UNDEF(&EG(user_exception_handler));
4610+
}
4611+
4612+
zend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1);
4613+
zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
4614+
zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
4615+
46024616
CG(map_ptr_last) = orig_map_ptr_last;
46034617

46044618
if (EG(full_tables_cleanup)) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
set_error_handler(function($_, $m) {
4+
static $x;
5+
var_dump($m);
6+
});
7+
8+
opcache_compile_file(__DIR__ . '/preload_error_handler_ind.inc');
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #81353: Segfault with preloading and error handler using static variables
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
opcache.preload={PWD}/preload_error_handler.inc
8+
--SKIPIF--
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
13+
--FILE--
14+
===DONE===
15+
--EXPECTF--
16+
Warning: Can't preload unlinked class B: Unknown parent A in %s on line %d
17+
===DONE===
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
// Cause a preload warning
4+
class B extends A {}

0 commit comments

Comments
 (0)