Thanks. I'll give that doc a read. Just to make sure, I noticed that the
doc is dated 2015, but the escape analysis implementation seemed to change
just recently from that implemented in esc.go to a new one in escape.go.
Dose the doc still apply to the new implementation?

On Thu, Mar 5, 2020 at 4:20 AM tokers <zchao1...@gmail.com> wrote:

> This is a known deficiency of Go's escape analysis, which is recorded in
> this doc:
> https://docs.google.com/document/d/1CxgUBPlx9iJzkz9JWkb6tIpTe5q32QDmz8l0BouG0Cw/view#
>
> On Thursday, March 5, 2020 at 5:58:37 AM UTC+8, burns...@gmail.com wrote:
>>
>> Hi All,
>>
>> I am trying to debug why a byte slice is escaping in my program. I have a
>> small reproducible example here:
>>
>> % cat escape.go
>> package main
>>
>> func main() {
>> x := make([]byte, 5)
>> y := new([]byte)
>> *y = x
>> nothing((*y)[3])
>> }
>>
>> func nothing(b byte) {}
>> % go tool compile -m -m -l escape.go
>> escape.go:4:11: make([]byte, 5) escapes to heap:
>> escape.go:4:11:   flow: x = &{storage for make([]byte, 5)}:
>> escape.go:4:11:     from make([]byte, 5) (spill) at escape.go:4:11
>> escape.go:4:11:     from x := make([]byte, 5) (assign) at escape.go:4:4
>> escape.go:4:11:   flow: {heap} = x:
>> escape.go:4:11:     from *y = x (assign) at escape.go:6:5
>> escape.go:4:11: make([]byte, 5) escapes to heap
>> escape.go:5:10: new([]byte) does not escape
>>
>> It seems to me like neither x nor it's backing array should escape, but
>> I'm having trouble figuring out why it's flagged as escaping from the debug
>> output.
>>
>> % go version
>> go version go1.14 darwin/amd64
>>
>>
>> Any help would be appreciated.
>>
>> Ethan
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/2s0_gQjR7yE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/646ff0ef-2feb-409b-9ac4-8c667b40b392%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/646ff0ef-2feb-409b-9ac4-8c667b40b392%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGE%3DEi2Bdzydu%2BzGHA0-xmMd0NTrBePBcTFAAvm1A-1RLiaa9Q%40mail.gmail.com.

Reply via email to