Skip to content

Core dumped in Zend/zend_generators.c #15866

Closed

Description

@YuanchengJiang

Description

The following code:

<?php
$db = new Pdo\Sqlite('sqlite::memory:');
class Canary {
public function __construct(public mixed $fusion) {}
}
function g() {
Fiber::suspend();
}
function f($canary) {
var_dump(yield from g());
}
$canary = new Canary(null);
$iterable = f($canary);
$fiber = new Fiber(function () use ($iterable, $canary) {
$f = $iterable->next(...);
$f();
});
$canary->value = $fiber;
$fiber->start();
$fiber = $iterable = $canary = null;
gc_collect_cycles();

Resulted in this output:

/php-src/Zend/zend_generators.c:218: check_node_running_in_fiber: Assertion `(executor_globals.flags) & (1<<0)' failed.
Aborted (core dumped)

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

Activity

  1. DanielEScherzer commented on Sep 17, 2024

    @DanielEScherzer
    Member

    Minimal reproduction:

    <?php
    $db = new Pdo\Sqlite('sqlite::memory:');
    
    function f() {
        yield from Fiber::suspend();
    }
    $canary = new stdClass();
    $iterable = f($canary);
    $fiber = new Fiber(function () use ($iterable) {
        $iterable->next();
    });
    $canary->value = $fiber;
    $fiber->start();
    $fiber = $iterable = $canary = null;
    gc_collect_cycles();
    

    Even removing the Sqlite database is enough for this to not fail, maybe that should be tagged with that label?

  2. ndossche commented on Sep 17, 2024

    @ndossche
    Member

    No, it seems you just need something that triggers a get_gc handler, and Pdo\Sqlite has a custom get_gc. So it's not directly related to that class.
    Anyway, cc @arnaud-lb since this code is his domain.

  3. self-assigned this
    on Sep 18, 2024
  4. arnaud-lb commented on Sep 24, 2024

    @arnaud-lb
    Member

    Indeed. The get_gc handler has the effect of changing the traversal order of the graph, and so of the dtor order.

  5. arnaud-lb commented on Oct 2, 2024

    @arnaud-lb
    Member

    Fixed by #16025.

    Thank you @YuanchengJiang!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions