[php-src] master: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Arnaud Le Blanc | Date: | Tue, 29 Sep 2026 16:09:48 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141696@lists.php.net to get a copy of this message | ||
Author: Arnaud Le Blanc (arnaud-lb)
Date: 2026-09-29T18:05:58+02:00
Commit: https://github.com/php/php-src/commit/cf8eefb7a650143f71c3c83c01a8632022482bda
Raw diff: https://github.com/php/php-src/commit/cf8eefb7a650143f71c3c83c01a8632022482bda.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Fix GH-23986: Clear the realpath cache in the child after pcntl_fork() (#23987)
Changed paths:
A ext/pcntl/tests/gh23986.phpt
M NEWS
M ext/pcntl/pcntl.c
M main/main.c
Diff:
diff --git a/NEWS b/NEWS
index e7b1ec270634..85401f4e5f77 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,8 @@ PHP NEWS
an exception is pending. (nicolas-grekas)
. Fixed pcntl_signal_dispatch() dropping the signals queued behind a handler
that throws. (nicolas-grekas)
+ . Fixed bug GH-23986 (/proc/self paths resolve to the parent process after
+ pcntl_fork()). (Lazizbek Ergashev)
- PDO:
. Fixed PDO::setAttribute() installing a PDO::ATTR_STATEMENT_CLASS class
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 0646e7ba043f..14f26291c045 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -27,6 +27,7 @@
#include "php.h"
#include "ext/standard/info.h"
+#include "ext/standard/php_filestat.h"
#include "php_signal.h"
#include "php_ticks.h"
#include "zend_exceptions.h"
diff --git a/ext/pcntl/tests/gh23986.phpt b/ext/pcntl/tests/gh23986.phpt
new file mode 100644
index 000000000000..7b9976d50079
--- /dev/null
+++ b/ext/pcntl/tests/gh23986.phpt
@@ -0,0 +1,29 @@
+--TEST--
+GH-23986 (/proc/self paths resolve to the parent process after pcntl_fork())
+--EXTENSIONS--
+pcntl
+--SKIPIF--
+<?php
+if (!is_readable('/proc/self/stat')) die('skip /proc/self/stat not available');
+?>
+--FILE--
+<?php
+function proc_self_pid() {
+ return (int) explode(' ', file_get_contents('/proc/self/stat'))[0];
+}
+
+var_dump(proc_self_pid() === getmypid());
+$parent_inode = fileinode('/proc/self');
+
+$pid = pcntl_fork();
+if ($pid === 0) {
+ var_dump(fileinode('/proc/self') !== $parent_inode);
+ var_dump(proc_self_pid() === getmypid());
+ exit(0);
+}
+pcntl_waitpid($pid, $status);
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
diff --git a/main/main.c b/main/main.c
index 0539220de362..3b82ae81f96c 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1814,6 +1814,7 @@ PHPAPI void php_child_init(void)
{
refresh_memory_manager();
zend_max_execution_timer_init();
+ php_clear_stat_cache(true, NULL, 0);
}
/* {{{ php_request_startup */