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
Found by the new tools/drop_audit.w matrix (the repo-committed drop auditor) on its first run — cell scope_exit/enum. Reproduces on the shipped compiler.
Repro (double-frees today)
extern fn with_alloc(size: i64) -> *mut u8
extern fn with_free(ptr: *mut u8) -> Unit
type R { id: i32, ptr: *mut u8, slot: *mut i32 }
impl Drop for R:
fn drop(move self: Self):
unsafe:
*self.slot = *self.slot + self.id
with_free(self.ptr)
fn mk(id: i32, slot: *mut i32) -> R:
unsafe { R { id: id, ptr: with_alloc(16), slot: slot } }
enum E:
Carry(R)
Empty
fn go(slot: *mut i32):
let a = E.Carry(mk(1, slot))
let _keep = 0
fn main:
var drops: i32 = 0
let slot = &raw mut drops
go(slot)
print_i32(drops)
with run --debug-alloc repro.w → DOUBLE FREE addr=… size=16 origin=with_alloc (the payload's allocation freed twice).
Scope and dating
Affected: EVERY control-flow shape with a live Drop-payload enum reaching scope exit — the auditor flags scope-exit, branch-taken, loop, move-out, reassign-over, move-then-reassign, early-return, normal-return (8 cells).
Not affected: let _ = E.Carry(mk(...)) discard and match-consume paths (the existing da_drop_enum_payload_discard.w lane fixture covers exactly the passing path — the plain-exit cell was covered nowhere until the auditor).
Struct-field / tuple / bare shapes are clean across the same 10 scenarios (auditor evidence), so the doubling is enum-payload-specific.
Next
Workflow per CLAUDE.md: --dump-drop-plan on the repro to see the two scheduled drops, then the MIR/codegen branch that emits the payload-propagation drop alongside the whole-value drop. The auditor cell pins the fix (with run tools/drop_audit.w <candidate> <baseline> — the 8 enum cells must flip DOUBLE-FREE → PASS with zero regressions elsewhere).
SQUASHED (4d42957, battery-green incl. the allocator lane, reseeded g4d4295743 + asset). The repro drops exactly once (7 / leak count=0), all 8 auditor enum cells flipped DOUBLE-FREE → PASS, and with build :drop-audit reads 60 cells, 0 non-PASS, 0 regressions — the gate's first fully green steady state.
Two independent doubles were stacked (why single-layer fixes kept failing during bring-up):
Root cause: the variant ctor never CONSUMED its moved payload operands (fields=[move _3]). The drop-state plan correctly marked the payload temp's scope-exit drop Moved→skip, but codegen's emission relies on the reset-on-move blank + ever-moved guard that only consume_moved_operand arms — so drop(_3) ran UNGUARDED on intact payload bytes. The ctor and assign_enum_variant_to_place now consume per field, the same discipline as every other move path.
The struct-field glue also walked USER-DECLARED enums' tag+payload layout (user enums are registered in the struct tables; generic-inst enums like Option miss them — which is exactly why only user enums doubled and the auditor's option cells passed). Payload cleanup now belongs exclusively to the variant-switched enum drop.
Hygiene: the ctor returned OK_COPY for non-Copy enums (two owners of one payload); now moves, Copy-gated.
Debug trail (for the record): drop-plan dump showed the plan was right → MIR dump showed the copy-not-move → emitted-IR call-site counting found TWO @R.drop calls under different dbg locations → an instrumented Drop (printed id twice) plus the unguarded-IR read pinned layer 1. lldb was uncooperative; the IR + instrumentation route was faster.
Pinned forever by test/debug_alloc/da_enum_payload_scope_exit.w (in every battery) and the auditor's enum row. Dating stands: introduced by the #606 payload-propagation era (v0.15.0 leaked instead of doubling — drops never ran at all).
Activity
Docs: handoff — #682-inc1 landed (33b8517); auditor discoveries #693/#…
Tools: drop-audit matrix as a repo-committed With tool + :drop-audit …
ehartford commentedon Jul 20, 2026
SQUASHED (4d42957, battery-green incl. the allocator lane, reseeded g4d4295743 + asset). The repro drops exactly once (
7/leak count=0), all 8 auditor enum cells flipped DOUBLE-FREE → PASS, andwith build :drop-auditreads 60 cells, 0 non-PASS, 0 regressions — the gate's first fully green steady state.Two independent doubles were stacked (why single-layer fixes kept failing during bring-up):
fields=[move _3]). The drop-state plan correctly marked the payload temp's scope-exit drop Moved→skip, but codegen's emission relies on the reset-on-move blank + ever-moved guard that onlyconsume_moved_operandarms — sodrop(_3)ran UNGUARDED on intact payload bytes. The ctor andassign_enum_variant_to_placenow consume per field, the same discipline as every other move path.Optionmiss them — which is exactly why only user enums doubled and the auditor's option cells passed). Payload cleanup now belongs exclusively to the variant-switched enum drop.OK_COPYfor non-Copy enums (two owners of one payload); now moves, Copy-gated.Debug trail (for the record): drop-plan dump showed the plan was right → MIR dump showed the copy-not-move → emitted-IR call-site counting found TWO
@R.dropcalls under different dbg locations → an instrumented Drop (printed id twice) plus the unguarded-IR read pinned layer 1. lldb was uncooperative; the IR + instrumentation route was faster.Pinned forever by
test/debug_alloc/da_enum_payload_scope_exit.w(in every battery) and the auditor's enum row. Dating stands: introduced by the #606 payload-propagation era (v0.15.0 leaked instead of doubling — drops never ran at all).MIR/Codegen: enum Drop-payload drops exactly once at scope exit (#693)
Docs: handoff — #693 squashed (4d42957); drop-audit steady state 60/0…
build: pin migrate-compiler-c memory cap off until the str flip; reco…