xref: /PHP-8.1/sapi/fpm/tests/gh8646.phpt (revision ff62d117)
1--TEST--
2GH-8646 (Memory leak PHP FPM 8.1)
3--EXTENSIONS--
4zend_test
5--SKIPIF--
6<?php include "skipif.inc"; ?>
7--FILE--
8<?php
9
10require_once "tester.inc";
11
12$cfg = <<<EOT
13[global]
14error_log = {{FILE:LOG}}
15[unconfined]
16listen = {{ADDR}}
17pm = dynamic
18pm.max_children = 5
19pm.start_servers = 1
20pm.min_spare_servers = 1
21pm.max_spare_servers = 3
22EOT;
23
24$code = <<<EOT
25<?php
26class MyClass {}
27echo zend_get_map_ptr_last();
28EOT;
29
30$tester = new FPM\Tester($cfg, $code);
31$tester->start();
32$tester->expectLogStartNotices();
33$map_ptr_last_values = [];
34for ($i = 0; $i < 10; $i++) {
35    $map_ptr_last_values[] = (int) $tester->request()->getBody();
36}
37// Ensure that map_ptr_last did not increase
38var_dump(count(array_unique($map_ptr_last_values, SORT_REGULAR)) === 1);
39$tester->terminate();
40$tester->expectLogTerminatingNotices();
41$tester->close();
42
43?>
44Done
45--EXPECT--
46bool(true)
47Done
48--CLEAN--
49<?php
50require_once "tester.inc";
51FPM\Tester::clean();
52?>
53