Package Usage: go: go4.org/unsafe/assume-no-moving-gc
Package go4.org/unsafe/assume-no-moving-gc exists so you can depend
on it from unsafe code that wants to declare that it assumes that
the Go runtime does not use a moving garbage collector. Specifically,
it asserts that the caller is playing stupid games with the addresses
of heap-allocated values. It says nothing about values that Go's escape
analysis keeps on the stack. Ensuring things aren't stack-allocated
is the caller's responsibility.
This package is then updated as needed for new Go versions when
that is still the case and explodes at runtime with a failure
otherwise, with the idea that it's better to not start at all than
to silently corrupt your data at runtime.
To use:
There is no API.
As of Go 1.21, this package asks the Go runtime whether it can move
heap objects around. If you get an error on versions prior to that,
go get go4.org/unsafe/assume-no-moving-gc@latest and things will
work.
The GitHub repo is at https://github.com/go4org/unsafe-assume-no-moving-gc
9 versions
Latest release: over 1 year ago
917 dependent packages
View more package details: https://packages.ecosystem.code.gouv.fr/registries/proxy.golang.org/packages/go4.org/unsafe/assume-no-moving-gc