-
Notifications
You must be signed in to change notification settings - Fork 18k
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: "escapes to heap" for arrays with capacity from variable regression #13093
Comments
Evidence (assembly language, and s/123/32000000) suggests that go 1.4 was in fact performing a heap allocation and not being entirely honest about it. So, not a bug.
makeslice calls newarray calls mallocgc. |
I think there is some conflation of concerns here. We must heap allocate if the value either escapes or is variable sized. go1.4 is correct in saying buf does not escape. Does escape analysis in 1.5 mark variable-sized allocations as escaping? That's not technically correct, but it's academic at this point because it will get heap allocated either way. But it may matter at some point in the future (per-goroutine private heaps? Function-local alias analysis?) |
For purposes of not losing our minds in the escape analysis code, "escapes" and "heap allocated" are one and the same. There are some latent bugs in the 1.4 escape-analysis code, some related to constant-but-very-large allocations being late-escaped to the heap -- and potentially dragging pointers to the stack with them because the allocation was moved after escape analysis ran. I think most people who care about this flag care about the "heap allocated" part, so perhaps we should change the message to be clearer? |
I see now, heap->stack pointers bad. Changing the message sounds good, although it might not be worth the big CL that would entail. |
Consider this simple example:
http://play.golang.org/p/mGfIERaXRL
array escapes to heap in 1.5, but does not escape in 1.4
The text was updated successfully, but these errors were encountered: