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] slicing an addressable array shares backing storage but records no may-share edge (primitive [N]T, HYB-E3003) #318
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 in0..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 in0..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.
Activity
Merge pr-319 (Taurahh, fixes limitlessprojects#318): freeze the array…
fix(hy-check): link addressable-array slices through copy and callee …