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
[soundness] scope_pop propagates freeze only over aliases, not may_share: shadowed struct-embedded map escapes the move of its holder (follow-up gap in #14/#31's fixes) #195
// shadow_may_share.hy
struct holder {
m map[string]int
}
fn worker(h holder, done chan<- bool) {
for i in0..100000 {
h.m["k"] = i
}
done <- true
}
fn main() {
m := map[string]int{"k": 0}
h := holder{m: m}
done := make(chan bool, 1)
if true {
m :=42
fmt.println(m)
task worker(move h, done)
}
for i in0..100000 {
m["k"] = i
}
<-done
}
hyb check shadow_may_share.hy → OK (0 diagnostics) (commit c09e9928, main)
hyb build shadow_may_share.hy -o app --emit-go && go run -race app.go → WARNING: DATA RACE (main goroutine vs main.worker on the same map), then fatal error: concurrent map writes, exit 2
What the checker should say
Reject the outer m["k"] = i (or the spawn): moving h must freeze every share peer of h — including the outer m that h.m aliases (GUARANTEES row 3: "embedding an alias does not launder it").
What it actually said
OK (0 diagnostics). Root cause: two interacting gaps in compiler/crates/hy-check/src/model.rs (scope_pop, ~lines 249-296):
When task worker(move h, done) marks the move, the freeze attempt resolves m via env_lookup_mut — which finds the inner shadowed m := 42 (a primitive) and marks it moved instead of the outer map binding.
On block exit, scope_pop propagates freeze across restored alias groups by iterating self.aliases only. The h ↔ m edge for h := holder{m: m} lives in self.may_share (struct-embedded references are not reference aliases), so the outer m is never frozen and the later write is accepted.
Claimed severity
P0 — data race reachable in the checked subset
Anything else
Violated: GUARANTEES.md row 3 (deep sendability / embedding an alias does not launder it) & row 6 (move/freeze), SPEC §9.3 O4.6/O5.
Activity
fix(hy-check): propagate freeze across may_share peers on scope_pop (f…
Merge pr-215 (area523ufo, fixes limitlessprojects#195): scope_pop swe…