php / php/php-src

PHP Embed SAPI not saving and restoring signal handlers.

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

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

Bug SAPI: embed Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

I would expect the the execution context to be restored following the PHP_EMBED_END_BLOCK() macro, but this doesn't seem to be the case for signal handlers.

here is a toy function to call a php function from a specified file:

/* Early work to call a php function from a specified script file */
void
call_php_function(char *file_name, char *function_name)
{
    zend_file_handle file_handle;
    zval retval = {0};
    zend_fcall_info fci = {0};
    zend_fcall_info_cache fci_cache = {0};

    sigset_t       oldsigset;
    struct sigaction oldsigaction[32] = {0,};

    some_signal_save_function(&oldsigset, oldsigaction);

    PHP_EMBED_START_BLOCK(0, NULL)
        zend_stream_init_filename(&file_handle, file_name);

        php_execute_script(&file_handle);

        ZVAL_STRING(&fci.function_name, function_name);

        fci.size = sizeof fci;
        fci.retval = &retval;

        zend_call_function(&fci, &fci_cache);
    PHP_EMBED_END_BLOCK()

    some_signal_restore_function(&oldsigset, oldsigaction);
}

Without the signal save/restore wrapping the embed block, the zend_signal_handler and defer handler is still handling the dispatching of signals, which is likely not what a user would want once outside an embed block.

PHP Version

7.4.27

Operating System

No response

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

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

はじめの一歩

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

調査の方向性

PHP_EMBED_START_BLOCK() マクロと PHP_EMBED_END_BLOCK() マクロから始め、zend_signal_handler と defer handler がどのようにインストールおよび削除されるかを追跡します。embed block の前後でシグナル状態を比較します。PHP_EMBED_END_BLOCK() の後に、シグナルハンドラと遅延シグナル処理が周囲のプロセスに対して復元されていれば完了です。

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

評価

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

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

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