Skip to content

Assertion failure zend_reference_destroy() #17736

Closed

Description

@YuanchengJiang

Description

The following code:

<?php
$xml = '<a><b></b></a>';
$o1 = new SimpleXMlElement($xml);
$o2 = clone $o1;
$r = current($o2->xpath('/a'));
$fusion = $r;
class C {
public int $a = 1;
}
function test(string $name, object $obj) {
$ref = &$obj->a;
}
$reflector = new ReflectionClass(C::class);
$obj = $reflector->newLazyGhost(function ($obj) {
});
test('Ghost', $obj);
test('Proxy', $fusion);

Resulted in this output:

php: /home/phpfuzz/WorkSpace/flowfusion/php-src/Zend/zend_variables.c:73: void zend_reference_destroy(zend_reference *): Assertion `!((ref)->sources.ptr != ((void*)0))' failed.
Aborted (core dumped)

PHP Version

nightly

Operating System

No response

Activity

  1. ndossche commented on Feb 8, 2025

    @ndossche
    Member

    Simplified:

    <?php
    $o1 = new SimpleXMlElement('<a/>');
    class C {
        public int $a = 1;
    }
    function test($obj) {
        $ref =& $obj->a;
    }
    $obj = new C;
    test($obj);
    test($o1);

    EDIT: this strongly looks like a cache slot issue

  2. ndossche commented on Feb 8, 2025

    @ndossche
    Member

    The call for zend_handle_fetch_obj_flags is not guarded by a CE check, which is what causes this issue.

  3. changed the title [-]Assertion failure zend_reference_destroy() Zend/zend_variables.c[/-] [+]Assertion failure zend_reference_destroy()[/+] on Feb 8, 2025
  4. added a commit that references this issue on Feb 23, 2025
    de4f7df
  5. added 2 commits that reference this issue on Mar 2, 2025
    ce8ab5f
    ee4a9a4
  6. added a commit that references this issue on Mar 2, 2025
    d95b9d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions