File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ GC with include in suspended coroutine - symTable double DELREF
3+ --FILE--
4+ <?php
5+
6+ use function Async \spawn ;
7+ use function Async \suspend ;
8+ use function Async \await ;
9+
10+ class Cycle {
11+ public $ self ;
12+ }
13+
14+ try {
15+ $ coroutine = spawn (function () {
16+ $ parent1 = "value1 " ;
17+ $ parent2 = "value2 " ;
18+
19+ for ($ i = 0 ; $ i < 10000 ; $ i ++) {
20+ $ obj = new Cycle ();
21+ $ obj ->self = $ obj ;
22+ }
23+
24+ // Suspend - coroutine is now in suspended state
25+ suspend ();
26+
27+ // Include inherits parent symTable
28+ // Bug: GC may add same variables twice -> double DELREF
29+ include __DIR__ . '/011-gc_include_symtable_double_delref_included.inc ' ;
30+
31+ echo "parent1: {$ parent1 }\n" ;
32+ echo "parent2: {$ parent2 }\n" ;
33+ echo "included: {$ included }\n" ;
34+
35+ return "done " ;
36+ });
37+
38+ $ result = await ($ coroutine );
39+ echo "result: {$ result }\n" ;
40+
41+ } catch (Error $ e ) {
42+ echo "Error: " . $ e ->getMessage () . "\n" ;
43+ }
44+
45+ echo "OK \n" ;
46+ gc_collect_cycles ();
47+ ?>
48+ --EXPECTF--
49+ parent1: value1
50+ parent2: value2
51+ included: included_value
52+ result: done
53+ OK
Original file line number Diff line number Diff line change 1+ <?php
2+ // Included file for GC test
3+ $ included = "included_value " ;
You can’t perform that action at this time.
0 commit comments