Skip to content

[soundness] Self-shadowing define (m := m) in an inner block drops the parameter/receiver non_owned_origin: move m accepted, data race #141

Closed

Description

@salvocanci

The smallest .hy program that demonstrates it

hyb built from main @ f99d6d0 (pinned go1.26.9 / rust 1.99.0).

package main

fn worker(m map[string]int, done chan bool) {
    for i in 0..1000 {
        m["k"] = i
    }
    done <- true
}

fn spawn(m map[string]int, done chan bool) {
    if true {
        m := m
        task worker(move m, done)
    }
}

fn main() {
    m := map[string]int{"k": 0}
    done := make(chan bool, 1)
    spawn(m, done)
    for i in 0..1000 {
        m["k"] = i
    }
    <-done
}
$ hyb check param.hy
$ hyb build param.hy -o out/param --emit-go && go vet out/param.go   # clean
$ go run -race out/param.go

What the checker should say

error[HYB-E3004]: cannot move m(map[string]int) — move requires an exclusively owned local binding, not parameterm`` (tier0_rule A1b), the same diagnostic main already gives for task worker(move m, done) directly and for `m2 := m; task worker(move m2, done)`. The inner `m` aliases the caller-owned parameter, so moving it into a task races with the caller's writes.

What it actually said

param.hy: OK (0 diagnostics)

and go run -race reports WARNING: DATA RACE (exit status 66).

Claimed severity

P0 — data race reachable in the checked subset

Anything else

Self-shadowing define (m := m, h := h, s := s, m := same(m)) in an inner block drops the shadowed binding's non_owned_origin (O5.1 guard from #61), because process_local defines the new binding before record_alias / record_may_share resolve the RHS ident, so they see the new inner binding. Same hole with a method receiver and a struct parameter. Fix with regression tests: #140.

Activity

  1. added a commit that references this issue on Oct 15, 2026
    3e53035
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