php / php/php-src

Assertion failure in check_node_running_in_fiber() when resuming a generator inside a Fiber destructor

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

还没有人认领这个 Issue。

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

描述

Description

The following code:

<?php
class a {
    static $b;
    static $max = 5.;
    function __destruct() {
        $a  = new a;
        static $gen = (function() {
            $from = (function () {
                $a = new a;
                yield;
            })();
            try {
                yield from $from;
            } finally {
            }
        })();
        $fiber = new Fiber(function () use ($gen, &$fiber) {
            $gen->next();
        });
        $fiber->start();
    }
}
new a;

Resulted in this output:

php: /path/to/php-src/Zend/zend_generators.c:217: _Bool check_node_running_in_fiber(zend_generator *): Assertion `generator->execute_data' failed.
Aborted

Commit:

56795d2810e

Build configuration:

CC="clang" CXX="clang++" CFLAGS="-fsanitize=address -g -O0" CXXFLAGS="-fsanitize=address -g -O0" LDFLAGS="-fsanitize=address" ./buildconf --force && ./configure --enable-debug --enable-address-sanitizer --disable-shared --with-pic --enable-mbstring --with-zlib
PHP Version
PHP 8.6.0-dev (cli) (built: Nov 29 2025 14:32:34) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.6.0-dev, Copyright (c), by Zend Technologies
Operating System

Ubuntu 22.04

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 Zend/zend_generators.c 中第 217 行附近的 check_node_running_in_fiber() 开始,然后使用 debug 和 AddressSanitizer 配置复现提供的脚本。跟踪对象销毁期间 generator 和 Fiber 的生命周期;当复现程序不再因 assertion 而中止,且回归覆盖验证了该行为时,即表示完成。

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

评估

技术栈
c, php
领域
backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

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