-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/compile: slightly unclear heap escape message (with -m) #16300
Comments
By the way, with tip, the
|
Yes, the explanation in the initial report is correct. The "readString" is a prefix to say which function is being reported. All the messages are supposed to have the prefix. Or else none should, but probably all. |
Apart from the readString prefix, should this be suffixed with " here" or " at this call"? |
Supposing the "does not escape" messages were removed, thus no-news-is-good-news, instead of the mixed bag that we have now? |
What is the compiler trying to say here? Is it saying, "I thought scratch was escaping to heap, but after closer analysis, now I see that it isn't?", is it trying to say, "scratch is not escaping to the heap at this particular point(i.e. 2nd reference escape)?", or is it saying something else entirely? |
I think the compiler is failing to admit that it was previously in error, and there is no way to call back that earlier false claim. It merely appears "after" because of an artifact of the line numbers at which it is discovered. Once something is determined to escape, it stays escaped. |
Thanks @dr2chase. That's too bad. One of the things I wish go could do better, function inline variable escape analysis. I won't pretend to understand the internals of this, but it seems if go escape analyzer could inline all inlineable functions first, then it might have better handle on which variables have potential for stack scope. |
Thanks, @josharian, let me take a look at that. Maybe it'll answer some of my puzzlings. |
When slicing an array, the compiler inserts an implicit OADDR operator, so
For the two call sites, One possible fix: do not print |
@dr2chase @cherrymui Is this going to be fixed for 1.10? If not lets roll the milestone forward. |
This "One possible fix: do not print |
I think this is fixed by https://go-review.googlesource.com/c/go/+/170319. With that CL, these messages are suppressed:
N.B., that this message (which is the most important one) is kept:
|
Change https://golang.org/cl/170319 mentions this issue: |
For most nodes (e.g., OPTRLIT, OMAKESLICE, OCONVIFACE), escape analysis prints "escapes to heap" or "does not escape" to indicate whether that node's allocation can be heap or stack allocated. These messages are also emitted for OADDR, even though OADDR does not actually allocate anything itself. Moreover, it's redundant because escape analysis already prints "moved to heap" diagnostics when an OADDR node like "&x" causes x to require heap allocation. Because OADDR nodes don't allocate memory, my escape analysis rewrite doesn't naturally emit the "escapes to heap" / "does not escape" diagnostics for them. It's also non-trivial to replicate the exact semantics esc.go uses for OADDR. Since there are so many of these messages, I'm disabling them in this CL by themselves. I modified esc.go to suppress the Warnl calls without any other behavior changes, and then used a shell script to automatically remove any ERROR messages mentioned by run.go in "missing error" or "no match for" lines. Fixes golang#16300. Updates golang#23109. Change-Id: I3993e2743c3ff83ccd0893f4e73b366ff8871a57
Tested with linux/amd64, go 1.6.2 and tip.
Consider the following function and
-gcflags -m
output:At first glance the two indicated lines seem to contradict each other. After consulting with some other folks I think that the last line ("x.go:224: readString scratch does not escape") means that the function call using scratch on line 224 does not itself cause scratch to escape, even though scratch does escape. Rather, it is the usage on line 221 that causes scratch to escape.
Perhaps the message could be reworded a bit.
/cc @dr2chase, I think?
The text was updated successfully, but these errors were encountered: