]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix heap pointer invariant rules in HACKING.md
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 28 Nov 2018 18:52:35 +0000 (18:52 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 30 Nov 2018 21:12:20 +0000 (21:12 +0000)
This change fixes an error in HACKING.md which claims all pointers
which live in unmanaged memory but point to the heap must be marked
as GC roots explicitly by runtime.markroot. This isn't technically
necessary if the pointer is accessible through a global variable.

Change-Id: I632b25272fdb2f789c5259dd1685d517f45fd435
Reviewed-on: https://go-review.googlesource.com/c/151539
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/HACKING.md

index 72ba61970bd67134bb77c84bbf54a91f3b2ed105..993edc67d886bb1d8181a85fac4a0df4e56ca9c8 100644 (file)
@@ -205,8 +205,10 @@ marked `//go:notinheap` (see below).
 Objects that are allocated in unmanaged memory **must not** contain
 heap pointers unless the following rules are also obeyed:
 
-1. Any pointers from unmanaged memory to the heap must be added as
-   explicit garbage collection roots in `runtime.markroot`.
+1. Any pointers from unmanaged memory to the heap must be garbage
+   collection roots. More specifically, any pointer must either be
+   accessible through a global variable or be added as an explicit
+   garbage collection root in `runtime.markroot`.
 
 2. If the memory is reused, the heap pointers must be zero-initialized
    before they become visible as GC roots. Otherwise, the GC may