On Fri, Feb 21, 2020 at 7:38 AM Iskander Sharipov <
quas...@gmail.com> wrote:
>
> If the original question is not clear, I can re-phrase it like this: what happens if a function marked with NO_LOCAL_POINTERS contains heap pointers on its frame?
>
> My understanding is that these pointers will not count as something that is a pointer and if there will be no other pointers to that data, it will be claimed by GC. But if there are other pointers that keep that data reachable, what are other consequences that can happen?
When the code calls gofunc1, it may find that there is not enough
stack space, which will cause the runtime to copy the stack to a new
location. When copying the stack the runtime will examine all
pointers on the stack, and, if they point to locations elsewhere on
the stack, adjust them to point to the new stack location. So if the
pointers passed to your function happen to point to locations on the
stack, and you use NO_LOCAL_POINTERS, then they will not be adjusted,
and your program will have dangling pointers leading to memory
corruption or other problems.
Ian
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/83b51508-0e2b-4d5b-80a7-97a3931ec5e4%40googlegroups.com.