mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Handle non-INDIRECT symbol table entries in zend_fiber_object_gc() (#10386)
Fixes GH-10340
This commit is contained in:
parent
1ceb2f3313
commit
36d55f8918
4 changed files with 80 additions and 2 deletions
19
Zend/tests/fibers/gh10340-001.phpt
Normal file
19
Zend/tests/fibers/gh10340-001.phpt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
--TEST--
|
||||||
|
Bug GH-10340 001 (Assertion in zend_fiber_object_gc())
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
function f() {
|
||||||
|
$$y = Fiber::getCurrent();
|
||||||
|
Fiber::suspend();
|
||||||
|
}
|
||||||
|
$fiber = new Fiber(function() {
|
||||||
|
get_defined_vars();
|
||||||
|
f();
|
||||||
|
});
|
||||||
|
$fiber->start();
|
||||||
|
gc_collect_cycles();
|
||||||
|
?>
|
||||||
|
==DONE==
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: Undefined variable $y in %s on line %d
|
||||||
|
==DONE==
|
19
Zend/tests/fibers/gh10340-002.phpt
Normal file
19
Zend/tests/fibers/gh10340-002.phpt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
--TEST--
|
||||||
|
Bug GH-10340 002 (Assertion in zend_fiber_object_gc())
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
function f() {
|
||||||
|
$y = 'a';
|
||||||
|
$$y = Fiber::getCurrent();
|
||||||
|
Fiber::suspend();
|
||||||
|
}
|
||||||
|
$fiber = new Fiber(function() {
|
||||||
|
get_defined_vars();
|
||||||
|
f();
|
||||||
|
});
|
||||||
|
$fiber->start();
|
||||||
|
gc_collect_cycles();
|
||||||
|
?>
|
||||||
|
==DONE==
|
||||||
|
--EXPECT--
|
||||||
|
==DONE==
|
38
Zend/tests/fibers/gh10340-003.phpt
Normal file
38
Zend/tests/fibers/gh10340-003.phpt
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
--TEST--
|
||||||
|
Bug GH-10340 003 (Assertion in zend_fiber_object_gc())
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class C {
|
||||||
|
public function __destruct() {
|
||||||
|
echo __METHOD__, "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f() {
|
||||||
|
$c = new C();
|
||||||
|
$y = 'a';
|
||||||
|
$$y = Fiber::getCurrent();
|
||||||
|
Fiber::suspend();
|
||||||
|
}
|
||||||
|
|
||||||
|
$fiber = new Fiber(function() {
|
||||||
|
get_defined_vars();
|
||||||
|
f();
|
||||||
|
});
|
||||||
|
|
||||||
|
$fiber->start();
|
||||||
|
|
||||||
|
print "1\n";
|
||||||
|
|
||||||
|
$fiber = null;
|
||||||
|
gc_collect_cycles();
|
||||||
|
|
||||||
|
print "2\n";
|
||||||
|
?>
|
||||||
|
==DONE==
|
||||||
|
--EXPECT--
|
||||||
|
1
|
||||||
|
C::__destruct
|
||||||
|
2
|
||||||
|
==DONE==
|
|
@ -674,8 +674,10 @@ static HashTable *zend_fiber_object_gc(zend_object *object, zval **table, int *n
|
||||||
if (lastSymTable) {
|
if (lastSymTable) {
|
||||||
zval *val;
|
zval *val;
|
||||||
ZEND_HASH_FOREACH_VAL(lastSymTable, val) {
|
ZEND_HASH_FOREACH_VAL(lastSymTable, val) {
|
||||||
ZEND_ASSERT(Z_TYPE_P(val) == IS_INDIRECT);
|
if (EXPECTED(Z_TYPE_P(val) == IS_INDIRECT)) {
|
||||||
zend_get_gc_buffer_add_zval(buf, Z_INDIRECT_P(val));
|
val = Z_INDIRECT_P(val);
|
||||||
|
}
|
||||||
|
zend_get_gc_buffer_add_zval(buf, val);
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
}
|
}
|
||||||
lastSymTable = symTable;
|
lastSymTable = symTable;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue