Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1190)

Issue 108870044: code review 108870044: cmd/gc: fix &result escaping into result (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 10 months ago by rsc
Modified:
9 years, 10 months ago
Reviewers:
iant
CC:
iant, golang-codereviews
Visibility:
Public.

Description

cmd/gc: fix &result escaping into result There is a hierarchy of location defined by loop depth: -1 = the heap 0 = function results 1 = local variables (and parameters) 2 = local variable declared inside a loop 3 = local variable declared inside a loop inside a loop etc In general if an address from loopdepth n is assigned to something in loop depth m < n, that indicates an extended lifetime of some form that requires a heap allocation. Function results can be local variables too, though, and so they don't actually fit into the hierarchy very well. Treat the address of a function result as level 1 so that if it is written back into a result, the address is treated as escaping. Fixes issue 8185.

Patch Set 1 #

Patch Set 2 : diff -r f153208c0a0e https://code.google.com/p/go/ #

Patch Set 3 : diff -r f153208c0a0e https://code.google.com/p/go/ #

Total comments: 1

Patch Set 4 : diff -r cb1af30a996c https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+23 lines, -2 lines) Patch
M src/cmd/gc/esc.c View 1 2 1 chunk +11 lines, -2 lines 0 comments Download
M test/escape2.go View 1 1 chunk +12 lines, -0 lines 0 comments Download

Messages

Total messages: 5
rsc
Hello iant (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
9 years, 10 months ago (2014-06-11 18:01:56 UTC) #1
iant
LGTM https://codereview.appspot.com/108870044/diff/30001/test/escape2.go File test/escape2.go (right): https://codereview.appspot.com/108870044/diff/30001/test/escape2.go#newcode1490 test/escape2.go:1490: x = &x // ERROR "&x escapes to ...
9 years, 10 months ago (2014-06-11 18:06:27 UTC) #2
rsc
On Wed, Jun 11, 2014 at 2:06 PM, <iant@golang.org> wrote: > https://codereview.appspot.com/108870044/diff/30001/test/ > escape2.go#newcode1490 > ...
9 years, 10 months ago (2014-06-11 18:17:09 UTC) #3
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=331dbd4a6334 *** cmd/gc: fix &result escaping into result There is a hierarchy ...
9 years, 10 months ago (2014-06-11 18:20:29 UTC) #4
iant
9 years, 10 months ago (2014-06-11 18:36:40 UTC) #5
On Wed, Jun 11, 2014 at 11:17 AM, Russ Cox <rsc@golang.org> wrote:
> On Wed, Jun 11, 2014 at 2:06 PM, <iant@golang.org> wrote:
>>
>>
>>
https://codereview.appspot.com/108870044/diff/30001/test/escape2.go#newcode1490
>> test/escape2.go:1490: x = &x // ERROR "&x escapes to heap"
>> It's astonishing that the many functions that do this have worked to
>> date.
>
>
> Do you know of any?
>
> &input is very common. &output seems like it would be rare.

I was joking.  &output is rare, and output = &output is probably non-existent.

Ian
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b