xref: /php-src/Zend/tests/bug77345_gc_2.phpt (revision 853b7945)
1--TEST--
2Bug #77345 (Segmentation faults stack overflow in cyclic garbage collector) (Bug #77427)
3--INI--
4zend.enable_gc = 1
5--FILE--
6<?php
7
8class Node
9{
10    /** @var Node */
11    public $previous;
12    /** @var Node */
13    public $next;
14}
15
16var_dump(gc_enabled());
17var_dump('start');
18
19function 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
41xxx();
42gc_collect_cycles();
43
44var_dump('end');
45?>
46--EXPECT--
47bool(true)
48string(5) "start"
49string(3) "end"
50