Skip to content

AOT: fix heap corruption in multi-variable interpolated echo (#23842) - #23864

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-23842-interp-two-vars
Jul 27, 2026
Merged

AOT: fix heap corruption in multi-variable interpolated echo (#23842)#23864
PurHur merged 1 commit into
masterfrom
agent/issue-23842-interp-two-vars

Conversation

@PurHur

@PurHur PurHur commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Root cause

#23798 correctly fixed in-place concat corrupting named locals, but also applied entry-alloca promotion to chained dead-temp concats (CONCAT($6,$6,$3)). That path intermittently heap-corrupted (7/10 runs on the issue repro). Before #23798: 15/15 green on the same repro.

Verification

# Issue repro — 30/30 runs green (was ~7/30 crash)
./script/docker-exec.sh -- bash -lc '
cat > /tmp/e1.php <<'"'"'PHP'"'"'
<?php $a = 5; $a--; $b = 9; $b--; echo "$a $b\n";
PHP
php bin/compile.php -o /tmp/e1 /tmp/e1.php
for i in $(seq 1 30); do /tmp/e1 || exit 1; done
echo OK
'
# OK

# AOT fixtures (4 tests including #23798 guard)
./script/docker-exec.sh -- bash -lc '"'"'source script/php-env.sh && vendor/bin/phpunit --filter "toplevel_interp_two_vars|concat_inline_echo_same_var|toplevel_incdec_echo" test/aot/AotTest.php'"'"'
# OK (4 tests, 20 assertions)

# Issue repro 1 (loop accumulator after prior inc/dec) — still green
./script/docker-exec.sh -- bash -lc 'php bin/compile.php -o /tmp/t test/differential/cases/g08_toplevel_incdec_echo.php && /tmp/t'
# 3\n5

Not covered

  • Full compliance suites, north-star5-verify-fast, differential sweep on this branch.

Closes #23842

Made with Cursor

Chained dead-temp CONCAT for encapsed strings with two script globals used
entry allocas on every link (#23798 regression). Route only the named-local
left-operand case through entry allocas; chained dead-temp links keep
KIND_VALUE temps like pre-#23798. Mark entry-alloca ephemeral concat results
to skip delref in freeDeadVariables.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit f98ba35 into master Jul 27, 2026
@PurHur
PurHur deleted the agent/issue-23842-interp-two-vars branch July 27, 2026 14:06
PurHur added a commit that referenced this pull request Jul 27, 2026
ConcatList emitted in-place CONCAT into one dead temp; with #23864 hybrid
that still double-freed on 3+/4-var interpolated echo. Use a fresh dest per
link, and continue ephemeral chains via KIND_VALUE without assignOperand
free/addref.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
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: script-scope ++/-- goes wrong once several statements or variables are involved (loop after statements, second variable)

1 participant