Skip to content

Regression: password_needs_rehash() nested password_hash() callee — fatal TYPE_DOUBLE typo (ext/standard/password.c) #17708

Description

@PurHur

Category

Regression · php-src-strict

Problem

password_needs_rehash() works when the hash string is bound to a variable, but fatals when password_hash() is nested as the first argument. Root cause includes VmPassword::algoTypeLabel() referencing nonexistent Variable::TYPE_DOUBLE (should be TYPE_FLOAT), masking the real argument-binding bug with an internal Error.

Repro Zend 8.2+ VM (2026-07-10)
password_needs_rehash($h, PASSWORD_BCRYPT, ['cost'=>4]) true/false per cost OK
password_needs_rehash(password_hash('x', PASSWORD_BCRYPT), PASSWORD_BCRYPT, ['cost'=>4]) true Fatal: Undefined constant Variable::TYPE_DOUBLE

php-src reference

PHP implementation target

  • ext/standard/VmPassword.php — fix algoTypeLabel() to use Variable::TYPE_FLOAT; audit nested-call arg slots in password_needs_rehash::execute()
  • ext/standard/password_needs_rehash.php — VM execute path
  • JIT: lib/JIT/JitPasswordNeedsRehash.php if the same mis-bind appears under LLVM

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_password_needs_rehash_nested_hash.php'

Done when

  • Nested and variable-bound calls agree with Zend on bcrypt cost compare
  • Mis-typed $algo surfaces TypeError, never internal TYPE_DOUBLE fatal
  • Compliance .phpt guard under test/compliance/cases/password/
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    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 Jul 10, 2026
  2. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  3. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #17708, #17707, #17709)

  4. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    Merged via #17727.

    Verification

    • php bin/vm.php test/repro/maintainer_gap_password_needs_rehash_nested_hash.php → ok
    • Nested call returns bool(true) matching variable-bound form (bcrypt cost 10 vs requested 4)
    • password_verify('x', password_hash(...)) nested callee also fixed by INIT deferral
    • Compliance: password_needs_rehash_nested_hash.phpt + JIT variant green
    • AOT compile-only: php bin/compile.php -l test/fixtures/aot/compile-only/password_needs_rehash_nested_hash.php exit 0
  5. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    Merged in PR #17728 — VM repro + compliance guards green. See PR body for verification transcript.

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 machinebugSomething isn't workingenhancementNew 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