Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

cmd/gc: escape analysis bug #3545

rsc opened this Issue Apr 18, 2012 · 3 comments


None yet
3 participants

rsc commented Apr 18, 2012

In the program below, 'i' is treated as not escaping, yet it does escape.  This can
cause crashes and memory corruption.

package main

import (

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)
       for t := range ch {
               fmt.Printf("%v %v\n", t, *t.v)

lvdlvd commented Apr 18, 2012

Comment 1:

how annoying.   I thought about it for a bit and wrote

lvdlvd commented Apr 23, 2012

Comment 2:

This issue was closed by revision 5583060.

Status changed to Fixed.

lvdlvd commented Apr 25, 2012

Comment 3:

This issue was closed by revision 4318c86ac48f.

@rsc rsc added this to the Go1.0.1 milestone Apr 14, 2015

@rsc rsc removed the go1.0.1 label Apr 14, 2015

rsc added a commit that referenced this issue May 11, 2015

[release-branch.go1] cmd/gc: fix addresses escaping through closures …
…called in-place.

««« backport a890477d3dfb
cmd/gc: fix addresses escaping through closures called in-place.

Fixes #3545.



@gopherbot gopherbot locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.