aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/cgocall.go
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2016-10-30 20:30:38 -0400
committerDavid Crawshaw <crawshaw@golang.org>2016-11-01 16:04:12 +0000
commit54ec7b072e017f7351f889f9f5b31bbf53a44119 (patch)
tree8e1520eca08765335b77ef904f4ad0f9a2d865b8 /src/runtime/cgocall.go
parent807a7ebd5107b44ca93849f2b12b61bc4cacca10 (diff)
downloadgo-54ec7b072e017f7351f889f9f5b31bbf53a44119.tar.gz
go-54ec7b072e017f7351f889f9f5b31bbf53a44119.zip
runtime: access modules via a slice
The introduction of -buildmode=plugin means modules can be added to a Go program while it is running. This means there exists some time while the program is running with the module is on the moduledata linked list, but it has not been initialized to the satisfaction of other parts of the runtime. Notably, the GC. This CL adds a new way of access modules, an activeModules function. It returns a slice of modules that is built in the background and atomically swapped in. The parts of the runtime that need to wait on module initialization can use this slice instead of the linked list. Fixes #17455 Change-Id: I04790fd07e40c7295beb47cea202eb439206d33d Reviewed-on: https://go-review.googlesource.com/32357 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/cgocall.go')
-rw-r--r--src/runtime/cgocall.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go
index 4542cb7b09..86091c7a4d 100644
--- a/src/runtime/cgocall.go
+++ b/src/runtime/cgocall.go
@@ -569,7 +569,7 @@ func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) (base, i uintptr) {
return
}
- for datap := &firstmoduledata; datap != nil; datap = datap.next {
+ for _, datap := range activeModules() {
if cgoInRange(p, datap.data, datap.edata) || cgoInRange(p, datap.bss, datap.ebss) {
// We have no way to know the size of the object.
// We have to assume that it might contain a pointer.
@@ -596,7 +596,7 @@ func cgoIsGoPointer(p unsafe.Pointer) bool {
return true
}
- for datap := &firstmoduledata; datap != nil; datap = datap.next {
+ for _, datap := range activeModules() {
if cgoInRange(p, datap.data, datap.edata) || cgoInRange(p, datap.bss, datap.ebss) {
return true
}