Skip to content

Stdlib: hash_pbkdf2() — enum case password operand must TypeError (ext/hash/hash.c, php-src-strict) #9027

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

hash_pbkdf2() must TypeError when $password (argument #2) is an enum case. This compiler coerces silently and completes (ok on repro).

Distinct from #6488 (openssl_pbkdf2 API missing).

php-src reference

Repro

test/repro/maintainer_hash_pbkdf2_enum_typeerror.php:

<?php
declare(strict_types=1);

enum E: string { case A = 'secret'; }

try {
    hash_pbkdf2('sha256', E::A, 'salt', 1000);
    echo "ok\n";
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_hash_pbkdf2_enum_typeerror.php
php bin/vm.php test/repro/maintainer_hash_pbkdf2_enum_typeerror.php
'
Engine Result
Zend hash_pbkdf2(): Argument #2 ($password) must be of type string, E given
VM (2026-06-16) ok (silent coercion of backing string)

Scope

  • ext/standard/hash_pbkdf2.php — enum reject via shared VmString::coerceStringBuiltinArg guard
  • JIT/AOT hash lowering if password arg is lowered separately

Done when

  • Repro prints TypeError on VM
  • Compliance PHPT: test/compliance/cases/stdlib/hash_pbkdf2_enum_operand.phpt

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 16, 2026
  2. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler Ext — I/O & Crypto — starting this run

  3. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    claim released: repro green on master — hash_pbkdf2(E::A) throws TypeError on VM matching Zend. Pivoting to #13135.

  4. PurHur commented on Jul 14, 2026

    @PurHur
    OwnerAuthor

    claim released: repro green on master — hash_pbkdf2_enum_case.phpt passes VM+JIT. Pivoting to hash_hmac_algos AOT list/in_array regression.

  5. PurHur commented on Jul 17, 2026

    @PurHur
    OwnerAuthor

    Unclaim (maintainer triage 2026-07-17): stale claim: with no linked PR (last claim 2026-07-10). Issue remains implementation-ready for the next worker.

  6. PurHur commented on Jul 17, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler Ext — I/O & Crypto — starting this run

  7. PurHur commented on Jul 17, 2026

    @PurHur
    OwnerAuthor

    Already fixed on master. VM and JIT compliance tests pass:

    $ php bin/vm.php test/repro/maintainer_hash_pbkdf2_enum_typeerror.php
    hash_pbkdf2(): Argument #2 ($password) must be of type string, E given
    
    $ php vendor/bin/phpunit --filter hash_pbkdf2_enum
    OK (2 tests, 2 assertions)
    

    The VmString::coerceStringBuiltinArg enum guard (line 197-203 of ext/standard/VmString.php) catches enum cases and throws TypeError via EnumCaseSupport::isEnumCaseVariable. Both the VM compliance test (hash_pbkdf2_enum_case.phpt) and JIT variant pass.

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 apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions