On Wed, Dec 20, 2017 at 1:54 AM, Jan Mercl <0xj...@gmail.com> wrote: > > On Wed, Dec 20, 2017 at 12:57 AM 'Keith Randall' via golang-nuts > <golang-nuts@googlegroups.com> wrote: > >> Pointers that point from a Go object to somewhere outside the Go heap are >> perfectly fine. > > Can you please specify the exact mechanism used by the runtime to determine > "is outside the Go heap"? I used unsafe.Pointers acquired from a memory > allocator[0] in one project and I sometimes experienced random crashes, > cause of which I'm really not certain about. I am currently rewriting that > project to use uintptrs only because of that and I would love to learn more > about this.
It's pretty simple. Current versions of Go use a single memory arena, with a start address and an end address. An arbitrary pointer value points into the Go heap if it points inside that arena. Otherwise, it points outside the Go heap. 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.