Skip to content

PHP 8.0 debug nts builds fail when unserializing circular array reference such as GLOBALS #308

Closed

Description

@TysonAndre

This is a result of the unserialization, not specifically of GLOBALS. The issue is that there are multiple references to the same hash table when unserializing an array when there are multiple references to that array

The standard serialize doesn't allow multiple pointers to an array

static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_string *key, zval *pData, uint32_t flag)
{
	zend_ulong h;
	uint32_t nIndex;
	uint32_t idx;
	Bucket *p, *arData;

	IS_CONSISTENT(ht);
	HT_ASSERT_RC1(ht); // this fails in debug builds
--TEST--
Test serialize globals
--SKIPIF--
<?php if (!extension_loaded("igbinary")) print "skip"; ?>
--FILE--
<?php
call_user_func(function () {
    foreach ($GLOBALS as $key => $_) {
        if ($key !== 'GLOBALS') {
            unset($GLOBALS[$key]);
        }
    }
    $ser = igbinary_serialize($GLOBALS);
    echo urlencode($ser) . "\n";
    var_dump(igbinary_unserialize($ser));
    $GLOBALS['globalVar'] = new stdClass();
    $ser = igbinary_serialize($GLOBALS);
    echo urlencode($ser) . "\n";
    var_dump(igbinary_unserialize($ser));
});
--EXPECTF--
0000000214011107474c4f42414c5314010e000101
array(1) {
  ["GLOBALS"]=>
  array(1) {
    ["GLOBALS"]=>
    *RECURSION*
  }
}
TODO fix

Activity

  1. changed the title [-]PHP 8.0 debug nts builds fail when unserializing circular array reference[/-] [+]PHP 8.0 debug nts builds fail when unserializing circular array reference such as GLOBALS[/+] on Dec 24, 2020
  2. added a commit that references this issue on Dec 4, 2021
    307e80e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions