Skip to content

A str read through a &str view owns its bytes (#2307) - #2308

Merged
ehartford merged 1 commit into
mainfrom
fix-2307
Oct 9, 2026
Merged

ehartford merged 1 commit into
mainfrom
fix-2307

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fixes #2307. Draft until its battery is green.

D111 lowered the copy of a view into a str as copy+retain, and
with_str_retain is a no-op for a pointer that is not the start of an owned
payload: a str stored from an interior view (`line.slice(..).trim()`)
shared bytes it did not hold and dangled once their temporary was freed
(MIR `_5 = copy+retain _24.*` then `drop(_21)`; under
WITH_DEBUG_ALLOC_SCRIBBLE the repro read freed memory; seed-driver flagged
every workflow pin). Codegen now reads a held str through a dereference
with with_str_own_view: a view that starts an owned payload is retained,
any other is copied. The repro prints [alpha] in 8 allocations, as before
D111; behav/da_2307 fail on the unfixed compiler ([3    ]).
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on 61eae8a (gate 617s, uat 92s, battery-checks 1181s, drop and move audits included).

@ehartford
ehartford marked this pull request as ready for review October 9, 2026 14:28
@ehartford
ehartford merged commit 1140e66 into main Oct 9, 2026
@ehartford
ehartford deleted the fix-2307 branch October 9, 2026 14:28
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.

D111: a str materialized from an interior &str view shares bytes it does not own (silent use-after-free)

1 participant