Skip to content

A parameter's completed effects survive the recheck of a concrete specialization - #3619

Merged
ehartford merged 1 commit into
mainfrom
effects-recheck
Nov 25, 2026
Merged

ehartford merged 1 commit into
mainfrom
effects-recheck

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

The bug. Any program that sorts with a closure (xs.sort_by((a, b) => …)) failed with analyze … audit:all: "effect edge … is not at fixpoint". Reproduced on main with a six-line program. No runtime symptom was found (a comparison that owns a list sorts with no double free and no leak under the debug allocator), but the effects table the later stages read was wrong for that instance.

Root cause, from the debugger. List.sort_by passes its comparison to by_compare, where it escapes into the returned closure. The effect fixpoint gives sort_by's parameter "consume + escapes". MIR lowering then checks each concrete specialization again (lower_concrete_specialization), and that recheck gives the signature fresh, zeroed effect slots (SemaCheck, where it already restores the value-ref flags for the same reason) and flushes only the body's own notes: "consume". The completed bit is gone.

The fix. Sema records that the fixpoint has run (effect_flow_settled). A signature re-registered after it starts from its completed effects, and the flush adds to them.

Two tool defects on the way, fixed here.

  • audit:effects run by itself aborted ("is_copy_frozen miss"): it ran as a snapshot before the copy-ness table it reads was complete, and before the rechecks it should judge. It now runs after MIR, as it does inside audit:all.
  • The audit named signatures by number only. It names both functions and prints both effect values.

Test. behav_effects_survive_specialization_recheck: run, audit:all, audit:effects. Shown failing before the fix (exit 134).

Evidence. Battery GREEN on e67a1c531 (the top of the stack this is the base of); :release-checks green on the same commit.

…cialization; audit:effects runs after MIR and names the functions
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.

1 participant