[php-src] Issue #19999: GC Reference Counting Assertion Failure via Object Destruction and Invalid Assignment

From: Date: Tue, 30 Sep 2025 05:32:08 +0000
Subject: [php-src] Issue #19999: GC Reference Counting Assertion Failure via Object Destruction and Invalid Assignment
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250945@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/19999 Author: vi3tL0u1s ### Description The following php input triggers a reference counting bug in PHP's Zend garbage collector: ```php <?php for ($i = 0; $a== 0; $h++) { $a += $i<6; class Test { static ?Test $test; function __destruct() { $GLOBALS['a'] = null; } } $a = [new Test]; Test::$test = $a<> 123^0-#x $a .= $a; } ?> ``` Resulted in this output: ``` Warning: Undefined variable $a in /home/student.unimelb.edu.au/viethoangl/id-31 on line 2 Warning: Undefined variable $a in /home/student.unimelb.edu.au/viethoangl/id-31 on line 3 Warning: Array to string conversion in /home/student.unimelb.edu.au/viethoangl/id-31 on line 17 php: Zend/zend_types.h:1383: uint32_t zend_gc_delref(zend_refcounted_h *): Assertion `p->refcount > 0' failed. Aborted ``` To reproduce: ```bash ./php-src-latest/sapi/cli/php poc.php ``` ### PHP Version ```plain PHP 8.5.0-dev (cli) (built: Sep 30 2025 15:04:00) (NTS DEBUG) Copyright (c) The PHP Group Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies with Zend OPcache v8.5.0-dev, Copyright (c), by Zend Technologies ``` ### Operating System Ubuntu 22.04

« previous php.bugs (#250945) next »