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

Wrong result with Fibers PHP 8.1 #133

Open
vtsykun opened this issue Feb 17, 2024 · 0 comments · May be fixed by #134
Open

Wrong result with Fibers PHP 8.1 #133

vtsykun opened this issue Feb 17, 2024 · 0 comments · May be fixed by #134

Comments

@vtsykun
Copy link

vtsykun commented Feb 17, 2024

STR

  1. Run the script.
namespace AAA;

$mem = new \ArrayObject([1, 2, 3]);
$_SERVER = [];
unset($argc, $argv);

$fiber = new \Fiber(static function() use ($mem): void {
    echo "Run from the Fiber...\n";

    while (true) {
        $i = 100;
        while ($i--) {
            $mem->offsetSet('a'.random_int(0, 2000000), 10);
        }
        echo "Count ". $mem->count() ."\n";
        \Fiber::suspend();
    }
});


$mem = null;
unset($mem);

gc_collect_cycles();

$fiber->start();

$fiber->resume();
\meminfo_dump(\fopen('/tmp/mem_dump.json', 'w'));
$fiber->resume();

Actual result: ArrayObject is missing in the memory dump.
Expected result: ArrayObject must be persist in the memory dump

mem_dump.json
{
  "header" : {
    "memory_usage" : 397944,
    "memory_usage_real" : 2097152,
    "peak_memory_usage" : 431256,
    "peak_memory_usage_real" : 2097152
  },
  "items": {
    "0x7f5691e58200" : {
        "type" : "array",
        "size" : "72",
        "symbol_name" : "_GET",
        "is_root" : true,
        "frame" : "<GLOBAL>"
,
        "children" : {

        }

    },
    "0x7f5691e58220" : {
        "type" : "array",
        "size" : "72",
        "symbol_name" : "_POST",
        "is_root" : true,
        "frame" : "<GLOBAL>"
,
        "children" : {

        }

    },
    "0x7f5691e58240" : {
        "type" : "array",
        "size" : "72",
        "symbol_name" : "_COOKIE",
        "is_root" : true,
        "frame" : "<GLOBAL>"
,
        "children" : {

        }

    },
    "0x7f5691e58260" : {
        "type" : "array",
        "size" : "72",
        "symbol_name" : "_FILES",
        "is_root" : true,
        "frame" : "<GLOBAL>"
,
        "children" : {

        }

    },
    "0x7f5691e14090" : {
        "type" : "null",
        "size" : "16",
        "symbol_name" : "argv",
        "is_root" : true,
        "frame" : "<GLOBAL>"


    },
    "0x7f5691e14080" : {
        "type" : "null",
        "size" : "16",
        "symbol_name" : "argc",
        "is_root" : true,
        "frame" : "<GLOBAL>"


    },
    "0x7f5691e582c0" : {
        "type" : "array",
        "size" : "72",
        "symbol_name" : "_SERVER",
        "is_root" : true,
        "frame" : "<GLOBAL>"
,
        "children" : {

        }

    },
    "0x7f5691e14070" : {
        "type" : "null",
        "size" : "16",
        "symbol_name" : "mem",
        "is_root" : true,
        "frame" : "<GLOBAL>"


    },
    "0x7f5691e5d640" : {
        "type" : "object",
        "size" : "72",
        "symbol_name" : "fiber",
        "is_root" : true,
        "frame" : "<GLOBAL>"
,
        "class" : "Fiber",
        "object_handle" : "2",
        "children" : {

        }

    }
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant