]> Cypherpunks repositories - gostls13.git/commit
runtime: add race instrumentation for moduleToTypelinksLock
authorchressie <chressie@golang.org>
Fri, 6 Feb 2026 15:05:22 +0000 (15:05 +0000)
committerCherry Mui <cherryyz@google.com>
Mon, 9 Feb 2026 17:32:14 +0000 (09:32 -0800)
commit1bb3f4ed2b045f0b10d0a66820681568c9b6377e
tree76d3de2a79f03bedba467bdc61c42e28b1b04cc0
parent9777ceceec8fee294d038182739cab7c845ad2d1
runtime: add race instrumentation for moduleToTypelinksLock

From Cherry Mui on the CL review:

The reason why we need race instrumentation is tricky. The runtime
package is not compiled with race instrumentation, therefore the race
detector doesn't know about synchronizations within the runtime, and
usually it doesn't care, as it also doesn't know about the concurrent
data accesses in the runtime.

However, in this case the concurrent access is in a map. Map accesses
are always instrumented
https://cs.opensource.google/go/go/+/master:src/internal/runtime/maps/runtime_fast64.go;l=25,
even if the map is defined in the runtime. So the race detector does see
the concurrent access. But it doesn't see the synchronization. So this
CL adds them.

Go maps are not common in the runtime. But I recall an issue like this
did occur. Maybe we could make the compiler/runtime not to instrument
map accesses for maps defined in the runtime (which would be a more
involved change).

---

The reproducer in src/runtime/testdata/testprog/typelinksrace.go was
provided by Cherry Mui.

Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
Reviewed-on: https://go-review.googlesource.com/c/go/+/742740
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/testdata/testprog/typelinksrace.go [new file with mode: 0644]
src/runtime/type.go
src/runtime/typelinksrace_test.go [new file with mode: 0644]