Category
stdlib | php-in-php
Problem
#6937 (closed) registered ext/hash skeleton stubs so function_exists('hash_init') is true, but hash_init() still throws Error: … not implemented in this compiler build (issue #3357). Streaming/incremental hashing and hash_copy() fork semantics are blocked for frameworks, file digest loops, and self-host paths that expect ext/hash parity.
Verified 2026-06-06:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_export(function_exists(\"hash_init\")); echo PHP_EOL; hash_init(\"sha256\");" 2>&1 | head -4
'
# true
# Fatal: hash_init() is not implemented in this compiler build (issue #3357)
php-src reference
Repro
<?php
$ctx = hash_init('sha256');
hash_update($ctx, 'hello ');
hash_update($ctx, 'world');
echo hash_final($ctx), "\n";
$ctx2 = hash_copy($ctx);
echo hash_final($ctx2), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro_hash_context.php
php bin/vm.php repro_hash_context.php 2>&1 | head -5
'
| Runtime |
Result |
| Zend |
Two identical SHA-256 hex lines for hello world |
| VM today |
hash_init() Error fatal |
Scope (PHP-in-PHP first)
| Path |
Work |
ext/hash/VmHashContext.php (new) |
Context state object; reuse digest backends from ext/standard/VmHashNative.php / VmHash.php |
ext/hash/hash_init.php et al. |
Replace stub throws with real handlers |
ext/hash/Module.php |
Wire HashContext builtin class (pairs #7084 __debugInfo) |
| JIT/AOT |
Defer after VM green; reuse #5989 digest lowering when ready |
| C runtime |
Do not extend lib/AOT/runtime/hash_crypto.c — shrink per #5989 |
php-src-strict
Done when
Category
stdlib|php-in-phpProblem
#6937 (closed) registered
ext/hashskeleton stubs sofunction_exists('hash_init')is true, buthash_init()still throwsError: … not implemented in this compiler build (issue #3357). Streaming/incremental hashing andhash_copy()fork semantics are blocked for frameworks, file digest loops, and self-host paths that expect ext/hash parity.Verified 2026-06-06:
php-src reference
ext/hash/hash.c—php_hash_init,php_hash_update,php_hash_final,php_hash_copyext/hash/hash.stub.php—HashContextobject model (PHP 8+)ext/hash/php_hash.h— context lifecycle (hash_finalinvalidates;hash_copyindependent clone)Repro
hello worldhash_init()Error fatalScope (PHP-in-PHP first)
ext/hash/VmHashContext.php(new)ext/standard/VmHashNative.php/VmHash.phpext/hash/hash_init.phpet al.ext/hash/Module.phpHashContextbuiltin class (pairs #7084__debugInfo)lib/AOT/runtime/hash_crypto.c— shrink per #5989php-src-strict
ValueError(match one-shothash()).TypeErrornaming enum class (Stdlib: hash()/hash_hmac()/md5()/sha1()/crc32() — enum case operands must TypeError (ext/hash, ext/standard) #5780 pattern), not backing scalar coercion.hash_final($ctx)invalidates$ctx; second final → catchable Error per Zend.Done when
hash_copy()produces independent context; updating one does not affect the othertest/compliance/cases/stdlib/hash_context_incremental.phptgreen underphp bin/vm.php./script/ci-fast.sh --filter hash_context_incrementalpasses