php / php/php-src

Segfault

未关闭
#11,655 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.1k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

Description

PHP config: https://paste.daniil.it/config

gdb backtrace:

(gdb) backtrace
#0  0x0000561fa234fd48 in ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER () at ./Zend/zend_vm_execute.h:56188
#1  execute_ex (ex=0x7fbe32a15630) at ./Zend/zend_vm_execute.h:56188
#2  0x0000561fa2354701 in zend_execute (op_array=0x7fbe32a7e000, return_value=0x0) at ./Zend/zend_vm_execute.h:60396
#3  0x0000561fa22e1e55 in zend_execute_scripts (type=type@entry=8, retval=retval@entry=0x0, file_count=file_count@entry=3) at ./Zend/zend.c:1827
#4  0x0000561fa227d3fa in php_execute_script (primary_file=<optimized out>) at ./main/main.c:2542
#5  0x0000561fa23cb50a in do_cli (argc=9, argv=0x561fa37bd170) at ./sapi/cli/php_cli.c:964
#6  0x0000561fa210dc5b in main (argc=9, argv=0x561fa37bd170) at ./sapi/cli/php_cli.c:1333

zbacktrace:

(gdb) zbacktrace
[0x7fbe32a15570] Zoon\Cache\Provider\Redis->getRedisClient() /zoon/zoon/vendor/zoon/cache/src/Provider/Redis.php:69
[0x7fbe32a15400] Zoon\Cache\Provider\Redis->getInternal("system_load_v2:z216:local_load", "") /zoon/zoon/vendor/zoon/cache/src/Provider/Redis.php:151
[0x7fbe32a15320] Zoon\Cache\Provider\CacheProvider->get("system_load_v2:z216:local_load", "") /zoon/zoon/vendor/zoon/cache/src/Provider/CacheProvider.php:144
// more stuff

Redis.php:69 is weird, because it points to the array_key_exists in closeRedisConnection, not the getRedisClient function mentioned in the backtrace, which by the way have the following code

        private function getRedisClient(): RedisClient {
                $pid = getmypid();
                $serverKey = "{$pid}:{$this->params['host']}:{$this->params['port']}";
                if (!array_key_exists($serverKey, self::$instances)) {
                        self::$instances[$serverKey] = new RedisClient(
                                $this->params['host'],
                                $this->params['port'],
                                $this->params['database'],
                                $this->params['connect_timeout'],
                                $this->params['max_reconnect'] ?? 0,
                        );
                }

                return self::$instances[$serverKey];
        }

        private function closeRedisConnection() {
                $pid = getmypid();
                $serverKey = "{$pid}:{$this->params['host']}:{$this->params['port']}";
                if (array_key_exists($serverKey, self::$instances)) {
                        try {
                                self::$instances[$serverKey]->close();
                        } catch (\Throwable $e) {
                                trigger_error($e->getMessage(), E_USER_WARNING);
                        } finally {
                                unset(self::$instances[$serverKey]);
                        }
                }
        }

Feel free to tag me if further inspection of the coredump is neeed.

ref: compressed_coredump-php.113283.1688702030

PHP Version

PHP 8.2.7

Operating System

Ubuntu 20.04, ondrej repos

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 gdb 和 zbacktrace 数据开始,重点查看 Zend/zend_vm_execute.h:56188、main/main.c:2542 和 vendor/zoon/cache/src/Provider/Redis.php:69;如果可用,请检查所引用的压缩 coredump。完成标准是确定 segfault 的可复现原因,并添加回归测试或其他经过验证的修复。

由索引模型根据 Issue 内容生成。

评估

技术栈
c, php
领域
backend, compilers
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。