Skip to content

Stdlib: gc_status() return shape — extra keys running/protected/full/buffer_size not in php-src (ext/standard/php_gc.c) #9970

Description

@PurHur

Category

stdlib · php-src-strict

Problem

gc_status() must return the associative array defined by php-src. On Zend PHP 8.2+, the array contains runs, collected, threshold, and roots only.

This compiler returns additional keys (running, protected, full, buffer_size) from CycleCollector::status(), breaking code that iterates keys, compares to Zend snapshots, or uses array_key_exists('running', gc_status()).

php-src reference

Repro

test/repro-maintainer/gc_status_shape.php:

<?php
$s = gc_status();
ksort($s);
echo implode(',', array_keys($s)), "\n";
var_export(array_key_exists('running', $s));
echo "\n";
var_export(array_key_exists('runs', $s));
echo "\n";

Commands

php test/repro-maintainer/gc_status_shape.php
# Zend keys: collected,roots,runs,threshold
# running: false

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro-maintainer/gc_status_shape.php'
# VM today: includes running,protected,full,buffer_size; running: true

Scope (PHP-in-PHP)

Path Work
lib/VM/CycleCollector.php status() — emit only php-src keys (or gate extras behind internal debug)
ext/standard/VmGcStatus.php statusTable() SSOT
lib/JIT/Builtin/GcStatusRuntime.php JIT must call PHP helper (#9150)
Tests test/compliance/cases/stdlib/gc_status_shape.phpt

PHP-in-PHP: shrink LLVM hashtable builder per #9150 once VM shape is correct.

Done when (php-src-strict)

  • array_keys(gc_status()) matches Zend set and order-insensitive equality
  • Numeric fields (runs, collected, threshold, roots) semantics match after gc_collect_cycles() smoke
  • No extra public keys unless documented as php-compiler-strict debug (default off)

Related

Activity

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

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions