Skip to content

AOT: fix concat ephemeral temp lifetime for dead echo/call operands (#23798) - #23827

Merged
PurHur merged 2 commits into
masterfrom
agent/issue-23798-concat-lifetime
Jul 27, 2026
Merged

AOT: fix concat ephemeral temp lifetime for dead echo/call operands (#23798)#23827
PurHur merged 2 commits into
masterfrom
agent/issue-23798-concat-lifetime

Conversation

@PurHur

@PurHur PurHur commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Dead php-cfg Concat temporaries (echo/call args) were lowered in-place into scope slots that can alias the concat left operand, corrupting the local on a second concat from the same variable.
  • Route operands in deadOperands through assignEphemeralConcatOperand: fresh __string__* in a dedicated entry alloca (KIND_VARIABLE) instead of in-place CONCAT or bare KIND_VALUE rvalues.
  • Extends AOT: emit concat for unallocated call-arg Temporaries (#23779) #23792 (call-arg emit) to cover single-arg calls and consecutive echo $s.'1'; echo $s.'2';.

Verification

# Issue reproducers (30× repro2 loop — was ~45% heap corruption)
php bin/compile.php -o /tmp/repro1 build/micro/argloc/repro1.php && /tmp/repro1   # → s1
php bin/compile.php -o /tmp/repro2 build/micro/argloc/repro2.php && /tmp/repro2   # → s1 / s2

# AOT fixtures (Docker)
./script/phpunit.sh test/aot/AotTest.php --filter concat_inline
# OK (3 tests, 15 assertions): concat_inline_call_args, concat_inline_call_arg_single, concat_inline_echo_same_var

Not run: script/differential-sweep.sh --aot (VM unaffected per issue), bootstrap/self-host gates (no compile-spine change).

Closes #23798

Made with Cursor

PurHur and others added 2 commits July 27, 2026 10:43
…nds (#23798)

Dead php-cfg Concat temps (echo/call args) were lowered in-place into scope
slots that alias the left operand, corrupting the local on a second concat.
Route dead operands through a dedicated entry alloca instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve TYPE_CONCAT conflict: keep ephemeral alloca path and thread
left/right operands into compileConcatIntoNewString (master API).

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

AOT: string concat result is freed too early — empty when passed to a function, free(): invalid pointer on reuse

1 participant