php / php/php-src

proc_open inaccessible cwd behavior change in 8.3

オープン
#13,743 コメント 18 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Category: Program Execution Extension: standard
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

As of PHP8.3, the following code:

<?php
$descriptorspec = array();
$cwd = '/inaccessible/dir/';
$process = proc_open('/usr/bin/env php -r ""', $descriptorspec, $pipes, $cwd);
proc_close($process);

Resulted in this output:

PHP Warning:  proc_open(): posix_spawn() failed: No such file or directory in /home/hans/test/test.php on line 4
PHP Fatal error:  Uncaught TypeError: proc_close(): Argument #1 ($process) must be of type resource, false given in /home/hans/test/test.php:5
Stack trace:
#0 /home/hans/test/test.php(5): proc_close()
#1 {main}
  thrown in /home/hans/test/test.php on line 5

But in PHP<8.3, it results in no output whatsoever, and proc_open succeeds.

This behavior change breaks real code in the wild: https://github.com/chrome-php/wrench/pull/20

While I think the behavior change is good, I also think a E_DEPRECATED period is warranted, something like

Requesting an inaccessible working dir ($cwd) has been deprecated and will stop working in a future version of PHP

  • Also for some unknown reason, when I test this locally, i get the posix_spawn() error, but when I test on Github CI, i don't get the posix_spawn() error (but proc_open() still fails.. silently.)
PHP Version

PHP8.3.0

Operating System

Ubuntu (both 22.04 and 24.04-beta)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、Ubuntu 上の PHP 8.3 で、提供された proc_open() と proc_close() の再現手順を、アクセスできない cwd を使用して実行し、ローカルの結果と GitHub CI の結果を比較します。posix_spawn() の失敗前後における proc_open() の動作を追跡し、次に期待される非推奨または失敗時の動作を定義して、異なる結果に対するカバレッジを追加します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, php
領域
operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。