Skip to content

[soundness] hy-check(closures): update_pre_defer_peers and update_post_defer_watch ignore field/index store assignments, allowing defer to race with task move (HYB-E3003) #4368

Description

@Mekdou23

Summary

On main (7cf29833), update_pre_defer_peers and update_post_defer_watch in compiler/crates/hy-check/src/closures.rs only match PlaceKind::Ident(target) in their Stmt::Assign arms and ignore field/index store assignments (PlaceKind::Field / PlaceKind::Index, such as b.m = m or b["k"] = m).

Because defer report(m) evaluates m eagerly at the defer statement, storing m into b.m (before or after defer report(m)), rebinding m = map[string]int{"k": 2} (which severs m from st.may_share["b"]), and moving b into task worker(move b) causes inspect_later_defer_fate to miss that b carries the deferred map storage. hyb check accepts with 0 diagnostics, resulting in a concurrent map write between the background task and the deferred report(m) at function exit (GUARANTEES.md Rows 1 & 5, HYB-E3003).

Minimal .hy Reproducer (Commit 7cf29833)

package main

struct box {
    m map[string]int
}

fn worker(b box) {
    b.m["k"] = 99
}

fn report(m map[string]int) {
    m["k"] = 1
}

fn main() {
    m := map[string]int{"k": 0}
    b := box{m: map[string]int{}}
    defer report(m)
    b.m = m
    m = map[string]int{"k": 2}
    task worker(move b)
}

Expected vs Actual

  • Expected: Verdict::Reject with HYB-E3003 (A1b).
  • Actual on 7cf29833: hyb check accepts with 0 diagnostics (Verdict::Accept).

Activity

  1. added 4 commits that reference this issue on Nov 12, 2026
    640adb1
    a026dda
    466b3ae
    28fc1b1
  2. added 3 commits that reference this issue on Nov 12, 2026
    34b4b81
    c94c08a
    449d533
  3. added a commit that references this issue on Nov 14, 2026
    ac0c134
  4. added a commit that references this issue on Nov 21, 2026
    1da43e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions