File tree Expand file tree Collapse file tree 3 files changed +64
-2
lines changed Expand file tree Collapse file tree 3 files changed +64
-2
lines changed Original file line number Diff line number Diff line change 5
5
- Core:
6
6
. Fixed --CGI-- support of run-tests.php. (cmb)
7
7
. Fixed incorrect double to long casting in latest clang. (zeriyoshi)
8
+ . Fixed bug GH-9266 (GC root buffer keeps growing when dtors are present).
9
+ (Michael Olšavský)
8
10
9
11
- Date:
10
12
. Fixed bug GH-8730 (DateTime::diff miscalculation is same time zone of
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GC 045: Total count persisted when GC is rerun due to destructor call
3
+ --INI--
4
+ zend.enable_gc=1
5
+ --FILE--
6
+ <?php
7
+ class GlobalData
8
+ {
9
+ public static Bar $ bar ;
10
+ }
11
+
12
+ class Value
13
+ {
14
+ public function __destruct ()
15
+ {
16
+ new Bar ();
17
+ }
18
+ }
19
+
20
+ class Bar
21
+ {
22
+ public function __construct ()
23
+ {
24
+ GlobalData::$ bar = $ this ;
25
+ }
26
+ }
27
+
28
+ class Foo
29
+ {
30
+ public Foo $ selfRef ;
31
+ public Value $ val ;
32
+
33
+ public function __construct (Value $ val )
34
+ {
35
+ $ this ->val = $ val ;
36
+ $ this ->selfRef = $ this ;
37
+ }
38
+ }
39
+
40
+ for ($ j = 0 ; $ j < 10 ; $ j ++) {
41
+ for ($ i = 0 ; $ i < 3000 ; $ i ++) {
42
+ new Foo (new Value ());
43
+ }
44
+ }
45
+
46
+ var_dump (gc_status ());
47
+ ?>
48
+ --EXPECT--
49
+ array(4) {
50
+ ["runs"]=>
51
+ int(10)
52
+ ["collected"]=>
53
+ int(25000)
54
+ ["threshold"]=>
55
+ int(10001)
56
+ ["roots"]=>
57
+ int(10000)
58
+ }
Original file line number Diff line number Diff line change @@ -1439,12 +1439,13 @@ static void zend_gc_root_tmpvars(void);
1439
1439
1440
1440
ZEND_API int zend_gc_collect_cycles (void )
1441
1441
{
1442
- int count = 0 ;
1442
+ int total_count = 0 ;
1443
1443
bool should_rerun_gc = 0 ;
1444
1444
bool did_rerun_gc = 0 ;
1445
1445
1446
1446
rerun_gc :
1447
1447
if (GC_G (num_roots )) {
1448
+ int count ;
1448
1449
gc_root_buffer * current , * last ;
1449
1450
zend_refcounted * p ;
1450
1451
uint32_t gc_flags = 0 ;
@@ -1622,6 +1623,7 @@ ZEND_API int zend_gc_collect_cycles(void)
1622
1623
1623
1624
GC_TRACE ("Collection finished" );
1624
1625
GC_G (collected ) += count ;
1626
+ total_count += count ;
1625
1627
GC_G (gc_active ) = 0 ;
1626
1628
}
1627
1629
@@ -1638,7 +1640,7 @@ ZEND_API int zend_gc_collect_cycles(void)
1638
1640
finish :
1639
1641
zend_get_gc_buffer_release ();
1640
1642
zend_gc_root_tmpvars ();
1641
- return count ;
1643
+ return total_count ;
1642
1644
}
1643
1645
1644
1646
ZEND_API void zend_gc_get_status (zend_gc_status * status )
You can’t perform that action at this time.
0 commit comments