You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MIR audit accepts compiler-generated resets through read-only borrowed fields #1096
The C4 emit-c-test failure in #1043 exposed a native MIR defect as well: a borrowed string field is cleared after lowering has already copied it into a local. analyze ... audit:all reports 11,245 facts and zero violations on the repro despite a store through the read-only &Holder parameter.
type Holder { text: str }
fn inspect(h: &Holder):
var text = h.text
print(text)
print(h.text)
fn main:
let h = Holder { text: "abc" }
inspect(h)
Expected: both prints are abc; the audit rejects writes through a read-only reference. Actual: the second line is empty and the audit is green. The emitted C fails compilation because this MIR store targets a const receiver.
MIR contains _3 = str_concat_n([copy _1.*.text, const ""]); _2 = move _3; _3 = const zst(str); _1.*.text = const zst(str);. The last store is invalid. Native LLDB on branch wo-c4 at b65817c observed MirBuilder.cancel_scheduled_value_drop_for_receiver_expr called from lower_let_binding after expected_type was restored to Unit (14), then queue_field_move_reset for borrowed field place 7. The compiler fix removes the redundant AST-level cancellation after assign_operand_to_place, which already consumes the actual lowered operand.
This issue tracks the silent audit/validator separately: validate write permission from the projected place's reference mode, including compiler-generated reset stores. Spec ownership signatures (§3.8) and D22 preserve read-only borrows. Do not exempt reset stores. Local evidence: out/c4-validation/borrowed-str-copy-inspect.tsv, borrowed-str-reset-lldb-confirmed.log, borrowed-str-copy-mir.log, borrowed-str-copy-audit.log. No workaround used.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): does not reproduce; 90d4858 ("consume lowered binding operands only once") stopped the clearing store.
$ cat main.w
type Holder { text: str }
fn inspect(h: &Holder):
var text = h.text
print(text)
print(h.text)
fn main:
let h = Holder { text: "abc" }
inspect(h)
$ with run main.w
abc
abc
$ with analyze main.w audit:all
compiler-analysis-audit: facts=20541 violations=0 ok
Activity
fix(mir): consume lowered binding operands only once
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): does not reproduce; 90d4858 ("consume lowered binding operands only once") stopped the clearing store.