diff options
Diffstat (limited to 'src/runtime/mfinal.go')
-rw-r--r-- | src/runtime/mfinal.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/runtime/mfinal.go b/src/runtime/mfinal.go index c07ea5e375..3cdb81e2fb 100644 --- a/src/runtime/mfinal.go +++ b/src/runtime/mfinal.go @@ -466,6 +466,10 @@ okarg: // Without the KeepAlive call, the finalizer could run at the start of // syscall.Read, closing the file descriptor before syscall.Read makes // the actual system call. +// +// Note: KeepAlive should only be used to prevent finalizers from +// running prematurely. In particular, when used with unsafe.Pointer, +// the rules for valid uses of unsafe.Pointer still apply. func KeepAlive(x interface{}) { // Introduce a use of x that the compiler can't eliminate. // This makes sure x is alive on entry. We need x to be alive |