php / php/php-src

File descriptors / some procfs entries not openable by php

オープン
#9,551 コメント 10 件 リアクション 2 件 担当者 0 名 GitHub で見る

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

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

説明

Description

The following code:

<?php
file_put_contents("/proc/1/fd/1", "hi");

Resulted in this output:

file_put_contents(/proc/1/fd/1): failed to open stream: No such file or directory

But I expected this output instead:

2

This is highly impactful for containerized PHP environments. php-fpm has unique workarounds that they've utilized, and in the past the fd stream wrapper was implemented to support managing the current process's file descriptors, but if you are in a different SAPI and/or utilize forking or execing to other PHP scripts, stdout in a docker container quickly turns into a black hole in terms of container logging, where it's expected that all logs are sent to the PID 1 stdout/err. See: https://bugs.php.net/bug.php?id=53465 where they hypothesize this is due to PHP incorrectly attempts to dereference the pseudo-symlink before opening it. The hypothesis makes sense to me. It'd be nice to see this fixed for all file descriptors.

PHP Version

7.4

Operating System

Centos 7.9

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

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

はじめの一歩

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

調査の方向性

ソースファイルもテストも指定されていません。まず /proc/1/fd/1 に対して PHP の例を再現し、擬似シンボリックリンクのデリファレンスに関するリンク先の bug を読んでから、procfs ディスクリプタのファイルオープン経路を追跡してください。/proc/1/fd/1 のようなディスクリプタを開くことができ、すべての SAPIs で期待される結果が得られれば完了です。

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

評価

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

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

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