aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mfinal.go
diff options
context:
space:
mode:
authorGerrit Code Review <noreply-gerritcodereview@google.com>2021-08-12 20:22:27 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-08-12 20:22:27 +0000
commit4d3cc84774549d26e52cbba3a0ffc50d3ede80d5 (patch)
treede3466e3b835e2c18fa03548ddf0619f5555575b /src/runtime/mfinal.go
parent7e9f911ec4fd08ce9b4296f0aea4864b53064573 (diff)
parenta64ab8d3ecb38e10007e136edc9dc3abde873e1e (diff)
downloadgo-4d3cc84774549d26e52cbba3a0ffc50d3ede80d5.tar.gz
go-4d3cc84774549d26e52cbba3a0ffc50d3ede80d5.zip
Merge "[dev.typeparams] all: merge master (46fd547) into dev.typeparams" into dev.typeparamsdev.typeparams
Diffstat (limited to 'src/runtime/mfinal.go')
-rw-r--r--src/runtime/mfinal.go4
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