We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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 8.4.0-dev
ubuntu 22.04
The text was updated successfully, but these errors were encountered:
At least PHP-8.3 is affected by this, too.
Sorry, something went wrong.
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.
array_merge_recursive()
convert_to_array($x)
Fixed by #16061.
Thank you @YuanchengJiang!
arnaud-lb
Successfully merging a pull request may close this issue.
Description
The following code:
Resulted in this output:
PHP Version
PHP 8.4.0-dev
Operating System
ubuntu 22.04
The text was updated successfully, but these errors were encountered: