Skip to content

Fix hash_init/update/final/copy AOT segfault (#3357)#18100

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-3357-hash-context-aot-fix
Jul 11, 2026
Merged

Fix hash_init/update/final/copy AOT segfault (#3357)#18100
PurHur merged 1 commit into
masterfrom
agent/issue-3357-hash-context-aot-fix

Conversation

@PurHur

@PurHur PurHur commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes AOT runtime segfault on hash_init() / hash_update() / hash_final() / hash_copy() while preserving working basic hash() AOT.

  • Root cause: hash_final/hash_copy routed through HashContextFinalLlvm/HashContextCopyLlvm bridge stubs and nested HashContextJitHelper string returns crashed in standalone user-script AOT.
  • Fix: Mirror __hcAlgo/__hcBuf on HashContext object slots; inline finalLowering/copyLowering in JitHashContext; use StringHashCryptoLlvm (__compiler_hash) for standalone AOT final path with __string__init clone before libcrypto digest.
  • JIT/VM path: unchanged nested-helper incremental semantics via HashContextJitHelper::finalize().

php-src reference: ext/hash/hash.c

Verification

./script/phpunit.sh --filter 'AotTest.*hash_context_incremental|AotTest.*hash_raw_output|HashModuleTest'
# OK (7 tests, 24 assertions)

php bin/compile.php -o /tmp/h test/repro/hash_context_incremental_aot.php && /tmp/h
# b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
# b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

php bin/jit.php test/repro/hash_context_incremental_aot.php   # green
php bin/vm.php test/repro/hash_context_incremental.php        # green

Closes #3357

Supersedes broken approach in #17897 (regressed basic hash() AOT).

Made with Cursor

…3357)

Standalone user-script AOT crashed in hash_final/hash_copy because nested
HashContextJitHelper string returns and LLVM bridge stubs were incompatible
with libcrypto __compiler_hash. Mirror algo/buf on HashContext object slots,
inline final/copy lowering, and re-init buffered data via __string__init
before EVP digest.

php-src: ext/hash/hash.c
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 727a4b7 into master Jul 11, 2026
@PurHur PurHur deleted the agent/issue-3357-hash-context-aot-fix branch July 11, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: hash_init() / hash_update() / hash_final() / hash_copy() — incremental ext/hash API

1 participant