Hacker News new | past | comments | ask | show | jobs | submit login

> Only store memory addresses in unsafe.Pointer.

> Perhaps only memory addresses allocated outside of the Go runtime (e.g. by direct calls to the mmap syscall).

> And even in that case Go’s not guaranteed not to change underneath you.

Note though, that runtime.Pinner, added in Go 1.21.0, can be used to safely rely on Go memory not moving (including passing pinned pointers to C code, which are then stored for no longer than the pointer remains pinned. Although, if the C code may copy nested pointers, I believe you also need to explicitly pin those, too.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: