File tree Expand file tree Collapse file tree 3 files changed +325
-83
lines changed Expand file tree Collapse file tree 3 files changed +325
-83
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #77345 (Segmentation faults stack overflow in cyclic garbage collector) (Bug #77427)
3
+ --INI--
4
+ zend.enable_gc = 1
5
+ --FILE--
6
+ <?php
7
+
8
+ class Node
9
+ {
10
+ /** @var Node */
11
+ public $ previous ;
12
+ /** @var Node */
13
+ public $ next ;
14
+ }
15
+
16
+ var_dump (gc_enabled ());
17
+ var_dump ('start ' );
18
+
19
+ $ firstNode = new Node ();
20
+ $ firstNode ->previous = $ firstNode ;
21
+ $ firstNode ->next = $ firstNode ;
22
+
23
+ $ circularDoublyLinkedList = $ firstNode ;
24
+
25
+ for ($ i = 0 ; $ i < 200000 ; $ i ++) {
26
+ $ currentNode = $ circularDoublyLinkedList ;
27
+ $ nextNode = $ circularDoublyLinkedList ->next ;
28
+
29
+ $ newNode = new Node ();
30
+
31
+ $ newNode ->previous = $ currentNode ;
32
+ $ currentNode ->next = $ newNode ;
33
+ $ newNode ->next = $ nextNode ;
34
+ $ nextNode ->previous = $ newNode ;
35
+
36
+ $ circularDoublyLinkedList = $ nextNode ;
37
+ }
38
+ var_dump ('end ' );
39
+ --EXPECT --
40
+ bool (true )
41
+ string (5 ) "start "
42
+ string (3 ) "end "
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #77345 (Segmentation faults stack overflow in cyclic garbage collector) (Bug #77427)
3
+ --INI--
4
+ zend.enable_gc = 1
5
+ --FILE--
6
+ <?php
7
+
8
+ class Node
9
+ {
10
+ /** @var Node */
11
+ public $ previous ;
12
+ /** @var Node */
13
+ public $ next ;
14
+ }
15
+
16
+ var_dump (gc_enabled ());
17
+ var_dump ('start ' );
18
+
19
+ function xxx () {
20
+ $ firstNode = new Node ();
21
+ $ firstNode ->previous = $ firstNode ;
22
+ $ firstNode ->next = $ firstNode ;
23
+
24
+ $ circularDoublyLinkedList = $ firstNode ;
25
+
26
+ for ($ i = 0 ; $ i < 300000 ; $ i ++) {
27
+ $ currentNode = $ circularDoublyLinkedList ;
28
+ $ nextNode = $ circularDoublyLinkedList ->next ;
29
+
30
+ $ newNode = new Node ();
31
+
32
+ $ newNode ->previous = $ currentNode ;
33
+ $ currentNode ->next = $ newNode ;
34
+ $ newNode ->next = $ nextNode ;
35
+ $ nextNode ->previous = $ newNode ;
36
+
37
+ $ circularDoublyLinkedList = $ nextNode ;
38
+ }
39
+ }
40
+
41
+ xxx ();
42
+ gc_collect_cycles ();
43
+
44
+ var_dump ('end ' );
45
+ --EXPECT --
46
+ bool (true )
47
+ string (5 ) "start "
48
+ string (3 ) "end "
You can’t perform that action at this time.
0 commit comments