Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/gc: escape analysis bug #3545

Closed
rsc opened this issue Apr 18, 2012 · 3 comments
Closed

cmd/gc: escape analysis bug #3545

rsc opened this issue Apr 18, 2012 · 3 comments

Comments

@rsc
Copy link
Contributor

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 (
       "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)
       }
}
@lvdlvd
Copy link

lvdlvd commented Apr 18, 2012

Comment 1:

how annoying.   I thought about it for a bit and wrote
http://golang.org/cl/6061043

@lvdlvd
Copy link

lvdlvd commented Apr 23, 2012

Comment 2:

This issue was closed by revision 5583060.

Status changed to Fixed.

@lvdlvd
Copy link

lvdlvd commented Apr 25, 2012

Comment 3:

This issue was closed by revision 4318c86ac48f.

@rsc rsc added fixed labels Apr 25, 2012
@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 pushed a commit that referenced this issue May 11, 2015
…called in-place.

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

Fixes #3545.

R=rsc
CC=golang-dev
https://golang.org/cl/6061043

»»»
@golang golang 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.
Projects
None yet
Development

No branches or pull requests

3 participants