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
In the program below, 'i' is treated as not escaping, yet it does escape. This can
cause crashes and memory corruption.
package main
import (
"fmt"
)
type T struct {
v *int
}
func foo(ch chan *T) {
i := 42
t := T{&i}
defer func() {
ch <- &t
}()
}
func main() {
ch := make(chan *T, 2)
foo(ch)
foo(ch)
close(ch)
for t := range ch {
fmt.Printf("%v %v\n", t, *t.v)
}
}
Activity
lvdlvd commentedon Apr 18, 2012
Comment 1:
lvdlvd commentedon Apr 23, 2012
Comment 2:
This issue was closed by revision 5583060.
Status changed to Fixed.
lvdlvd commentedon Apr 25, 2012
Comment 3:
This issue was closed by revision 4318c86ac48f.
[release-branch.go1] cmd/gc: fix addresses escaping through closures …