Skip to content

Assertion in zend_fiber_object_gc() #10340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dstogov opened this issue Jan 16, 2023 · 1 comment · Fixed by #10386
Closed

Assertion in zend_fiber_object_gc() #10340

dstogov opened this issue Jan 16, 2023 · 1 comment · Fixed by #10386

Comments

@dstogov
Copy link
Member

dstogov commented Jan 16, 2023

Description

The following code:

<?php
function f() {
    $$y = Fiber::getCurrent();
    Fiber::suspend();
}
$fiber = new Fiber(function() {
    get_defined_vars();
    f();
});
$fiber->start();
gc_collect_cycles();
?>
DONE

Resulted in this output:

DONE

But I expected this output instead:

Zend/zend_fibers.c:659: zend_fiber_object_gc: Assertion `zval_get_type(&(*(val))) == 12' failed.

PHP creates IS_INDIRECT zvals to keep real zvals in CVs but have "pointers" in the symbol table. However, it's possible to create a variable in symbol table without CV. (e.g using $$). So variables don't have to be IS_INDIRECT. May be non IS_INDIRECT values should be just skipped.

The bug was found by google oss-fuzz.

PHP Version

PHP-8.1

Operating System

@arnaud-lb
Copy link
Member

Thank you for the pointers. I've pushed a PR here: #10386

May be non IS_INDIRECT values should be just skipped.

I've tried that in the PR, but I've had to handle them so that the cycle in Zend/tests/fibers/gh10340-003.phpt could be collected.

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

Successfully merging a pull request may close this issue.

2 participants