Skip to content

Broken RC inference for op1 of FETCH_OBJ with magic methods #17151

Closed
@iluuu1994

Description

@iluuu1994

Description

The following code:

<?php

class C {
    public function __get($name) {
        return $this;
    }
}

function test() {
    $x = (new C)->bar;
    var_dump($x);
}

test();

Resulted in this output:

php: Zend/zend_objects_API.c:162: zend_objects_store_del: Assertion `zend_gc_refcount(&(object)->gc) == 0' failed. 

But I expected this output instead:

object(C)#%d (0) {
}

The problem here is that we don't create a new definition for op1 for FETCH_OBJ. This was discovered during development of GH-17130.

PHP Version

PHP 8.2+

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions