From f096b5b340f6e831cf80cd39cbf88d4656d232fa Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 4 Aug 2017 10:36:40 -0700 Subject: runtime: mark activeModules nosplit/nowritebarrier The activeModules function is called by the cgo pointer checking code, which is called by the write barrier (when GODEBUG=cgocheck=2), and as such must be nosplit/nowritebarrier. Fixes #21306 Change-Id: I57f2124f14de7f3872b2de9532abab15df95d45a Reviewed-on: https://go-review.googlesource.com/53352 Reviewed-by: Austin Clements --- misc/cgo/errors/ptr.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'misc/cgo/errors') diff --git a/misc/cgo/errors/ptr.go b/misc/cgo/errors/ptr.go index 4dafbdf3c0..3e117666bf 100644 --- a/misc/cgo/errors/ptr.go +++ b/misc/cgo/errors/ptr.go @@ -343,6 +343,14 @@ var ptrTests = []ptrTest{ body: `var b C.char; p := &b; C.f((*C.u)(unsafe.Pointer(&p)))`, fail: false, }, + { + // Issue #21306. + name: "preempt-during-call", + c: `void f() {}`, + imports: []string{"runtime", "sync"}, + body: `var wg sync.WaitGroup; wg.Add(100); for i := 0; i < 100; i++ { go func(i int) { for j := 0; j < 100; j++ { C.f(); runtime.GOMAXPROCS(i) }; wg.Done() }(i) }; wg.Wait()`, + fail: false, + }, } func main() { -- cgit v1.3