Skip to content
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

Assertion failure in Zend/zend_hash.c #16053

Open
YuanchengJiang opened this issue Sep 25, 2024 · 2 comments · May be fixed by #16061
Open

Assertion failure in Zend/zend_hash.c #16053

YuanchengJiang opened this issue Sep 25, 2024 · 2 comments · May be fixed by #16061

Comments

@YuanchengJiang
Copy link

Description

The following code:

<?php
class test
{
}
$x = new test;
$fusion = $x;
$arrays = array (
array(1 => "hello", "string" => $fusion, $heredoc),
);
$arr2 = array( 1 => "one", 2, "string" => "hello", "array" => array("a", "b", "c"));
foreach($arrays as $arr1) {
var_dump( array_merge_recursive($arr1) );
var_dump( array_merge_recursive($arr1, $arr2) );
}

Resulted in this output:

/php-src/Zend/zend_hash.c:1091: zval *_zend_hash_index_add_or_update_i(HashTable *, zend_ulong, zval *, uint32_t): Assertion `(zend_gc_refcount(&(ht)->gc) == 1) || ((ht)->u.flags & (1<<6))' failed.
Aborted (core dumped)

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

@cmb69
Copy link
Member

cmb69 commented Sep 25, 2024

At least PHP-8.3 is affected by this, too.

@arnaud-lb
Copy link
Member

arnaud-lb commented Sep 25, 2024

Smaller reproducer:

<?php
class test
{
}
$x = new test;
$arr1 = array("string" => $x);
$arr2 = array("string" => "hello");
var_dump($x);
var_dump(array_merge_recursive($arr1, $arr2));

array_merge_recursive() assumes that the result of convert_to_array($x) has RC=1, which is not always the case.

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.

3 participants