Skip to content

Commit d894080

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Reduce HT_MAX_SIZE to account for the max load factor of 0.5 (#10242) GC fiber unfinished executions (#9810)
2 parents a8c387e + 0f7625c commit d894080

15 files changed

+495
-52
lines changed

Zend/tests/fibers/gh9735-001.phpt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Bug GH-9735 001 (Fiber stack variables do not participate in cycle collector)
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
$fiber = new Fiber(function () {
13+
$c = new C();
14+
15+
$fiber = Fiber::getCurrent();
16+
17+
Fiber::suspend();
18+
});
19+
20+
print "1\n";
21+
22+
$fiber->start();
23+
gc_collect_cycles();
24+
25+
print "2\n";
26+
27+
$fiber = null;
28+
gc_collect_cycles();
29+
30+
print "3\n";
31+
32+
?>
33+
--EXPECT--
34+
1
35+
2
36+
C::__destruct
37+
3

Zend/tests/fibers/gh9735-002.phpt

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Bug GH-9735 002 (Fiber stack variables do not participate in cycle collector)
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
function f() {
13+
Fiber::suspend();
14+
}
15+
16+
$fiber = new Fiber(function () {
17+
$c = new C();
18+
19+
$fiber = Fiber::getCurrent();
20+
21+
f();
22+
});
23+
24+
print "1\n";
25+
26+
$fiber->start();
27+
gc_collect_cycles();
28+
29+
print "2\n";
30+
31+
$fiber = null;
32+
gc_collect_cycles();
33+
34+
print "3\n";
35+
36+
?>
37+
--EXPECT--
38+
1
39+
2
40+
C::__destruct
41+
3

Zend/tests/fibers/gh9735-003.phpt

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Bug GH-9735 003 (Fiber stack variables do not participate in cycle collector)
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
function f() {
13+
$fiber = Fiber::getCurrent();
14+
Fiber::suspend();
15+
}
16+
17+
$fiber = new Fiber(function () {
18+
$c = new C();
19+
20+
f();
21+
});
22+
23+
print "1\n";
24+
25+
$fiber->start();
26+
gc_collect_cycles();
27+
28+
print "2\n";
29+
30+
$fiber = null;
31+
gc_collect_cycles();
32+
33+
print "3\n";
34+
35+
?>
36+
--EXPECT--
37+
1
38+
2
39+
C::__destruct
40+
3

Zend/tests/fibers/gh9735-004.phpt

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Bug GH-9735 004 (Fiber stack variables do not participate in cycle collector)
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
function f() {
13+
$fiber = Fiber::getCurrent();
14+
Fiber::suspend();
15+
}
16+
17+
$fiber = new Fiber(function () {
18+
$c = new C();
19+
20+
preg_replace_callback('#.#', f(...), '.');
21+
});
22+
23+
print "1\n";
24+
25+
$fiber->start();
26+
gc_collect_cycles();
27+
28+
print "2\n";
29+
30+
$fiber = null;
31+
gc_collect_cycles();
32+
33+
print "3\n";
34+
35+
?>
36+
--EXPECT--
37+
1
38+
2
39+
C::__destruct
40+
3

Zend/tests/fibers/gh9735-005.phpt

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--TEST--
2+
Bug GH-9735 005 (Fiber stack variables do not participate in cycle collector)
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
function f() {
13+
Fiber::suspend();
14+
}
15+
16+
$fiber = new Fiber(function () {
17+
$c = new C();
18+
19+
$fiber = Fiber::getCurrent();
20+
21+
// Force symbol table
22+
get_defined_vars();
23+
24+
f();
25+
});
26+
27+
print "1\n";
28+
29+
$fiber->start();
30+
gc_collect_cycles();
31+
32+
print "2\n";
33+
34+
$fiber = null;
35+
gc_collect_cycles();
36+
37+
print "3\n";
38+
39+
?>
40+
--EXPECTF--
41+
1
42+
2
43+
C::__destruct
44+
3

Zend/tests/fibers/gh9735-006.phpt

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--TEST--
2+
Bug GH-9735 006 (Fiber stack variables do not participate in cycle collector)
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
function f() {
13+
// Force symbol table
14+
get_defined_vars();
15+
16+
Fiber::suspend();
17+
}
18+
19+
$fiber = new Fiber(function () {
20+
$c = new C();
21+
22+
$fiber = Fiber::getCurrent();
23+
24+
// Force symbol table
25+
get_defined_vars();
26+
27+
f();
28+
});
29+
30+
print "1\n";
31+
32+
$fiber->start();
33+
gc_collect_cycles();
34+
35+
print "2\n";
36+
37+
$fiber = null;
38+
gc_collect_cycles();
39+
40+
print "3\n";
41+
42+
?>
43+
--EXPECTF--
44+
1
45+
2
46+
C::__destruct
47+
3

Zend/tests/fibers/gh9735-007.phpt

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--TEST--
2+
Bug GH-9735 007 (Fiber stack variables do not participate in cycle collector)
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
function f() {
13+
$fiber = Fiber::getCurrent();
14+
15+
// Force symbol table
16+
get_defined_vars();
17+
18+
Fiber::suspend();
19+
}
20+
21+
$fiber = new Fiber(function () {
22+
$c = new C();
23+
24+
// Force symbol table
25+
get_defined_vars();
26+
27+
f();
28+
});
29+
30+
print "1\n";
31+
32+
$fiber->start();
33+
gc_collect_cycles();
34+
35+
print "2\n";
36+
37+
$fiber = null;
38+
gc_collect_cycles();
39+
40+
print "3\n";
41+
42+
?>
43+
--EXPECTF--
44+
1
45+
2
46+
C::__destruct
47+
3

Zend/tests/fibers/gh9735-008.phpt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
Bug GH-9735 008 (Fiber stack variables do not participate in cycle collector)
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
function f($a, $b) {
13+
}
14+
15+
function g() {
16+
Fiber::suspend();
17+
}
18+
19+
$fiber = new Fiber(function () {
20+
$c = new C();
21+
22+
f(Fiber::getCurrent(), g());
23+
});
24+
25+
print "1\n";
26+
27+
$fiber->start();
28+
gc_collect_cycles();
29+
30+
print "2\n";
31+
32+
$fiber = null;
33+
gc_collect_cycles();
34+
35+
print "3\n";
36+
37+
?>
38+
--EXPECTF--
39+
1
40+
2
41+
C::__destruct
42+
3

Zend/tests/fibers/gh9735-009.phpt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
Bug GH-9735 009 (Fiber stack variables do not participate in cycle collector)
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
function f($a, $b) {
13+
}
14+
15+
function g() {
16+
g(Fiber::suspend());
17+
}
18+
19+
$fiber = new Fiber(function () {
20+
$c = new C();
21+
22+
f(Fiber::getCurrent(), g());
23+
});
24+
25+
print "1\n";
26+
27+
$fiber->start();
28+
gc_collect_cycles();
29+
30+
print "2\n";
31+
32+
$fiber = null;
33+
gc_collect_cycles();
34+
35+
print "3\n";
36+
37+
?>
38+
--EXPECTF--
39+
1
40+
2
41+
C::__destruct
42+
3

0 commit comments

Comments
 (0)