Debian Codegraph @

assume-no-moving-gc.go

raw symbols SCIP
1 // Copyright 2020 Brad Fitzpatrick. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package go4.org/unsafe/assume-no-moving-gc exists so you can depend
6 // on it from unsafe code that wants to declare that it assumes that
7 // the Go runtime does not use a moving garbage collector. Specifically,
8 // it asserts that the caller is playing stupid games with the addresses
9 // of heap-allocated values. It says nothing about values that Go's escape
10 // analysis keeps on the stack. Ensuring things aren't stack-allocated
11 // is the caller's responsibility.
12 //
13 // This package is then updated as needed for new Go versions when
14 // that is still the case and explodes at runtime with a failure
15 // otherwise, with the idea that it's better to not start at all than
16 // to silently corrupt your data at runtime.
17 //
18 // To use:
19 //
20 // import _ "go4.org/unsafe/assume-no-moving-gc"
21 //
22 // There is no API.
23 //
24 // As of Go 1.21, this package asks the Go runtime whether it can move
25 // heap objects around. If you get an error on versions prior to that,
26 // go get go4.org/unsafe/assume-no-moving-gc@latest and things will
27 // work.
28 //
29 // The GitHub repo is at https://github.com/go4org/unsafe-assume-no-moving-gc
30 package assume_no_moving_gc
31
32 const env = "ASSUME_NO_MOVING_GC_UNSAFE"