Repository navigation
Fix strlen() value-box AOT lowering — dangling blocks silently terminated binaries (#15632) - #15640
Merged
Merged
Conversation
This was referenced Jul 3, 2026
…y terminated AOT binaries (#15632) df16f37 (#11263) added a non-strict null-coercion branch to JitStrlen::lowerLengthFromValueBox that returned const 0 with the builder still positioned in the null block, leaving okBlock (the real-string path) and coerceBlock dangling with no terminator. Any non-constant-folded strlen() in an AOT binary fell off the empty block: process exited 0 mid-output. MCJIT masked it (boxed locals lower differently under bin/jit.php), so only phpc build binaries died. Restructure the non-strict path so all live paths (null -> 0 with deprecation, Stringable object -> coerced length, plain -> coerced length) branch to a shared done block and merge via phi, mirroring JitLongArg::lowerValueBoxToLong. Verified in php-compiler:22.04-dev (LLVM 9), AOT vs VM parity: $x="abc"; echo strlen($x) -> 3 + continues (was: silent exit 0) null operand (non-strict) -> 0 + continues strict_types=1 string -> 6 + continues examples/000 AOT -> Hello World phpunit --filter Strlen -> identical failure set to master (9 pre-existing failures, none introduced; Stringable AOT length mismatch pre-exists and is tracked separately) Root cause of #15624 first layer; multipart $_FILES needs the remaining broken builtins (preg_match capture assign, explode CRLF, str_contains, substr negative length) tracked in the follow-up issue. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PurHur
force-pushed
the
fix/15632-strlen-aot-valuebox
branch
from
July 3, 2026 21:19
0c4c3f2 to
8aafc61
Compare
Owner
Author
|
Rebased onto master after #15641 landed. #15641's null-path phi kept the non-strict objectBlock early return, so plain-string strlen still silently killed binaries (verified at 8250d40: repro prints nothing, exit 0). This PR now completes it on top of master: object path merges via phi, merge block only appended in non-strict mode (was a new dangling block on strict scripts), phi incomings use getInsertBlock() instead of block labels. Re-verified after rebase (Docker LLVM 9): plain 3+after · null 0+after · strict 6+after · Stringable continues (length parity tracked in #15642) · examples/000 Hello World · phpunit --filter Strlen: same 9 pre-existing failures as master, #15641's new tests pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15632. First layer of #15624.
Root cause
df16f37d4(#11263) added the non-strict null-coercion branch toJitStrlen::lowerLengthFromValueBox()with an earlyreturnwhile the builder was positioned in the null block.okBlock(the real-string path) was never populated — a dangling basic block with no terminator — so every AOT binary fell through undefined behavior at its first non-constant-foldedstrlen()and exited 0 silently. The same early-return pattern also orphanedcoerceBlockvia the object branch. MCJIT (bin/jit.php) masked the bug because typed locals don't take the value-box path there.Fix
All live non-strict paths (null → deprecation + 0, Stringable object → coerced length, plain value → coerced length) now branch to a shared
strlen_value_len_doneblock and merge viaphi, mirroring the existingJitLongArg::lowerValueBoxToLongidiom. Strict-mode behavior unchanged.Verification (php-compiler:22.04-dev, LLVM 9)
$x="abc"; echo strlen($x); echo "after";3+after3+after0+ continues0+ continuesstrict_types=1, string66bin/jit.phprepro33phpunit --filter Strlen: failure set identical to master (9 pre-existing, 0 introduced — verified by diffing failing data-set names against a pristine master tree). Known remaining gap (pre-existing): Stringable object strlen returns 0 in AOT vs 4 on VM — landed inside the broken window (#13480), tracked separately.🤖 Generated with Claude Code