PHP Embed SAPI not saving and restoring signal handlers.
未关闭
还没有人认领这个 Issue。
Bug
SAPI: embed
Status: Needs Triage
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.2k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 PHP_EMBED_START_BLOCK() 和 PHP_EMBED_END_BLOCK() 宏开始,跟踪 zend_signal_handler 和 defer handler 的安装与移除方式。比较嵌入块前后的信号状态;在 PHP_EMBED_END_BLOCK() 之后,如果信号处理程序和延迟信号处理都已针对外围进程恢复,则表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, php
- 领域
- backend, operating-systems
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100