Skip to content

[soundness] slicing an addressable array shares backing storage but records no may-share edge (primitive [N]T, HYB-E3003) #318

Closed

Description

@Taurahh

Bounty #5 submission.

On 44a08b96dca77e49cf8c6469d8c177ef908b5234, hyb check accepts this program with 0 diagnostics. Expected: HYB-E3003 (rule A1b) on the later write to a[0]. A slice of an array parameter should be HYB-E3004.

fn worker(s []int, done chan<- bool) {
    for i in 0..200000 { s[0] = i }
    done <- true
}
fn main() {
    var a [4]int
    a[0] = 1
    s := a[:]
    done := make(chan bool, 1)
    task worker(move s, done)
    for i in 0..200000 { a[0] = i }
    <-done
}

Emitted Go is s := a[:], go worker(s, done), then a[0] = i. go run -race (go1.22.2) reports WARNING: DATA RACE on that slot and exits 66.

shape_may_share recurses into an array only when an element may share. [N]int therefore records no edge for s := a[:], s := b.data[:], row := g[i][:], or append(a[0:1], x) (spare capacity keeps the append inside the array). move freezes the slice and not the array. Two overlapping windows (a[0:2] moved into two tasks) and ch <- move s are the same hole.

Controls that must stay accepted: b := a moved as [4]int, []int{a[0], a[1]}, and clone(a)[:] when clone returns the array by value. Reslicing a []int is already HYB-E3003. task worker(a[:]) with no local is already HYB-E3001.

Not #131 and not #188. Not #253, #293, #305, or #306.

Severity: P0. An accepted program has a data race. Fix PR to follow.

Activity

  1. added a commit that references this issue on Oct 17, 2026
    0c0ef74
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