AOT: fix heap corruption in multi-variable interpolated echo (#23842) - #23864
Merged
Conversation
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
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>
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.
Summary
free(): invalid pointerwhen AOT-compiled scripts use two script globals in one interpolated echo (echo "$a $b\n") — a regression from AOT: string concat result is freed too early — empty when passed to a function, free(): invalid pointer on reuse #23798 (AOT: fix concat ephemeral temp lifetime for dead echo/call operands (#23798) #23827) that routed every chained dead-temp CONCAT through entry allocas.echo $s.'1'fix); chained dead-temp links ($t = $a.' '; $t .= $b) revert to KIND_VALUE temps like pre-AOT: string concat result is freed too early — empty when passed to a function, free(): invalid pointer on reuse #23798.ephemeralConcatTempsofreeDeadVariablesdoes not delref strings already copied by echo'smaterializeStringSlot.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
Not covered
north-star5-verify-fast, differential sweep on this branch.Closes #23842
Made with Cursor