Skip to content

Commit 49bc011

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 5252e8b + af8ebb1 commit 49bc011

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

sapi/fpm/fpm/fpm_status.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ int fpm_status_export_to_zval(zval *status)
6262

6363
/* copy the scoreboard not to bother other processes */
6464
scoreboard = *scoreboard_p;
65-
struct fpm_scoreboard_proc_s procs[scoreboard.nprocs];
65+
struct fpm_scoreboard_proc_s *procs = safe_emalloc(
66+
sizeof(struct fpm_scoreboard_proc_s), scoreboard.nprocs, 0);
6667

6768
struct fpm_scoreboard_proc_s *proc_p;
6869
for(i=0; i<scoreboard.nprocs; i++) {
@@ -132,6 +133,8 @@ int fpm_status_export_to_zval(zval *status)
132133
add_next_index_zval(&fpm_proc_stats, &fpm_proc_stat);
133134
}
134135
add_assoc_zval(status, "procs", &fpm_proc_stats);
136+
efree(procs);
137+
135138
return 0;
136139
}
137140
/* }}} */
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--TEST--
2+
FPM: GH-16432 - fpm_get_status segfault on high nprocs
3+
--SKIPIF--
4+
<?php include "skipif.inc"; ?>
5+
--FILE--
6+
<?php
7+
8+
require_once "tester.inc";
9+
10+
$cfg = <<<EOT
11+
[global]
12+
error_log = {{FILE:LOG}}
13+
log_level = notice
14+
[unconfined]
15+
listen = {{ADDR}}
16+
pm = dynamic
17+
pm.max_children = 12800
18+
pm.start_servers = 1
19+
pm.min_spare_servers = 1
20+
pm.max_spare_servers = 1
21+
catch_workers_output = yes
22+
EOT;
23+
24+
$code = <<<EOT
25+
<?php
26+
var_dump(empty(fpm_get_status()));
27+
EOT;
28+
29+
$tester = new FPM\Tester($cfg, $code);
30+
[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName();
31+
$tester->start();
32+
$tester->expectLogStartNotices();
33+
$tester->request()->expectBody('bool(false)');
34+
$tester->terminate();
35+
$tester->expectLogTerminatingNotices();
36+
$tester->close();
37+
38+
?>
39+
Done
40+
--EXPECT--
41+
Done
42+
--CLEAN--
43+
<?php
44+
require_once "tester.inc";
45+
FPM\Tester::clean();
46+
?>

0 commit comments

Comments
 (0)