Skip to content

Regression: hash_algos() returns NULL as in_array() haystack — nested call operand (ext/standard/array.c hash.c) #11313

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

hash_algos() returns a string list array when assigned or passed to var_export(), but evaluates to NULL when nested directly as the haystack argument to in_array(). Zend returns true for in_array('md5', hash_algos(), true).

Workaround today: assign hash_algos() to a variable first.

php-src reference

Repro (failure today)

test/repro/maintainer_hash_algos_in_array.php:

<?php
declare(strict_types=1);

var_export(in_array('md5', hash_algos(), true));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_hash_algos_in_array.php
php bin/vm.php test/repro/maintainer_hash_algos_in_array.php'
Runtime Output
Zend PHP 8.2 true
VM today Fatal TypeError: haystack must be array, null given ❌

Contrast (works on VM):

$algos = hash_algos();
var_export(in_array('md5', $algos, true));

Scope (this repo)

Path Work
ext/standard/ hash builtin lowering Ensure hash_algos() materializes array when used as call argument
lib/VM.php / operand evaluation Fix nested-builtin temp lifetime if VM drops array between arg evals
Tests test/compliance/cases/stdlib/hash_algos_in_array.phpt

PHP-in-PHP: implement/fix in ext/standard + VM operand path; avoid C hash table duplication in runtime/.

Done when

  • Repro prints true on VM
  • in_array('xxh3', hash_algos(), true) works when xxh3 registered
  • Assignment and direct-nested forms agree (php-src-strict)

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 24, 2026
  2. PurHur commented on Jun 24, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #11313, #11322, #11323)

  3. PurHur commented on Jun 24, 2026

    @PurHur
    OwnerAuthor

    Already fixed on master before this batch — in_array('md5', hash_algos(), true) returns true on VM (verified 2026-06-24).

  4. PurHur commented on Jun 24, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #11313, #11365, #11366)

  5. PurHur commented on Jun 24, 2026

    @PurHur
    OwnerAuthor

    Triage 2026-06-24: repro from issue description passes on current master (VM matches Zend). No code change needed in this batch — please close if maintainer confirms.

  6. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — batch (issues #11313, #11366, #9547) — compiler regression from #11409 inlineCallArgProducerPassesByRefGuards

  7. added a commit that references this issue on Jun 25, 2026
  8. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    Merged via #11427.

    Root cause: #11409 (#11422) changed inlineCallArgProducerPassesByRefGuards to return $feedsConsumerArg, which rejected producers when operand identity did not link producer.result to callee slots (e.g. in_array('md5', hash_algos(), true)).

    Fix: Keep scoped named-local/by-ref checks from #11409, but return true when no fed-arg violations (position/dead-temp matching still applies).

    Verification (VM matches Zend):

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php bin/vm.php test/repro/maintainer_hash_algos_in_array.php
    php bin/vm.php test/repro/maintainer_gap_nested_array_builtin_arg.php
    vendor/bin/phpunit --filter testInArrayNestedHashAlgosRuntime
    '
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