Repository navigation
Merged
Conversation
…address (#2025) A read-mode `fn` receiver is typed `&Self` but held as the caller's place, so mir_capture_source_ptr returned that place as the capture's storage; the closure loaded the receiver's own bytes as the `&Self` and faulted (lldb: EXC_BAD_ACCESS address=0x5, the receiver's count field, at the inlined __closure). A reference-typed source gets a slot holding the address, as any reference local has.
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.
Stacked on #2034. Fixes #2025.
A closure in a read-mode
fnmethod that reads the receiver segfaulted when called through afn(..)parameter or amapstage (mut fn/move fnwere fine).Route (CLAUDE.md, codegen bug): lldb on the built repro stopped at the inlined
__closurewith EXC_BAD_ACCESS address=0x5 — the receiver'scountfield read as an address.--dump-mirshowed the cause: the read receiver local is typed&Cand marked[caller-place], and the closure body reads_1.*.countthrough its by-place capture. Codegen holds that receiver as the caller's place (mir_indirect_value_local_types), somir_capture_source_ptrhanded the closure the address of theCitself rather than a slot holding the&C.Fix (codegen owns representation, D65):
mir_capture_source_ptrgives a reference-typed indirect source a slot holding its address. Capture modes are unchanged, so this is independent of #2029's Sema capture record (that branch leaves this function as it is).Evidence: new
test/behavior/behav_closure_captures_read_receiver.wsegfaulted (rc=139) on the #2034 stage1 and passes after the fix. It coversself.count, a barecount(§9.5), a|> map(it + count)stage, and themut fncase.--debug-allocreports leak count=0,--validate-allis ok, the 46 closure/capture behavior tests pass,:gateis green, and:drop-auditshows 254 cells with 0 regressions.