[go] runtime: add race instrumentation for moduleToTypelinksLock

4 views
Skip to first unread message

Chressie Himpel (Gerrit)

unread,
Feb 6, 2026, 10:46:09 AM (17 hours ago) Feb 6
to goph...@pubsubhelper.golang.org, Cherry Mui, golang-co...@googlegroups.com
Attention needed from Cherry Mui

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
Gerrit-Change-Number: 742740
Gerrit-PatchSet: 2
Gerrit-Owner: Chressie Himpel <chre...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Comment-Date: Fri, 06 Feb 2026 15:46:03 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Feb 6, 2026, 1:50:58 PM (14 hours ago) Feb 6
to Chressie Himpel, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Cherry Mui, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Chressie Himpel

Ian Lance Taylor added 1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Ian Lance Taylor . resolved

We don't have to add explicit raceacquire calls for other locks in the runtime. What is different about this one?

Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Chressie Himpel
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
Gerrit-Change-Number: 742740
Gerrit-PatchSet: 2
Gerrit-Owner: Chressie Himpel <chre...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Chressie Himpel <chre...@google.com>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Comment-Date: Fri, 06 Feb 2026 18:50:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Feb 6, 2026, 1:54:02 PM (14 hours ago) Feb 6
to Chressie Himpel, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Cherry Mui, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Chressie Himpel

Ian Lance Taylor added 1 comment

Patchset-level comments
Ian Lance Taylor . resolved

We don't have to add explicit raceacquire calls for other locks in the runtime. What is different about this one?

Ian Lance Taylor

Or, to put it another way, how can I reproduce the problem? "go test -race reflect" doesn't do it. I don't see any failures on the build dashboard.

Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Chressie Himpel
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
Gerrit-Change-Number: 742740
Gerrit-PatchSet: 2
Gerrit-Owner: Chressie Himpel <chre...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Chressie Himpel <chre...@google.com>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Comment-Date: Fri, 06 Feb 2026 18:53:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Ian Lance Taylor <ia...@golang.org>
unsatisfied_requirement
satisfied_requirement
open
diffy

Cherry Mui (Gerrit)

unread,
Feb 6, 2026, 4:13:16 PM (12 hours ago) Feb 6
to Chressie Himpel, goph...@pubsubhelper.golang.org, Ian Lance Taylor, golang-co...@googlegroups.com
Attention needed from Chressie Himpel and Ian Lance Taylor

Cherry Mui added 1 comment

Patchset-level comments
Ian Lance Taylor . resolved

We don't have to add explicit raceacquire calls for other locks in the runtime. What is different about this one?

Ian Lance Taylor

Or, to put it another way, how can I reproduce the problem? "go test -race reflect" doesn't do it. I don't see any failures on the build dashboard.

Cherry Mui

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).

I'll see if I can work out a reproducer.

Thanks.

Open in Gerrit

Related details

Attention is currently required from:
  • Chressie Himpel
  • Ian Lance Taylor
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
Gerrit-Change-Number: 742740
Gerrit-PatchSet: 2
Gerrit-Owner: Chressie Himpel <chre...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Chressie Himpel <chre...@google.com>
Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
Gerrit-Comment-Date: Fri, 06 Feb 2026 21:13:13 +0000
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Feb 6, 2026, 5:33:51 PM (10 hours ago) Feb 6
to Chressie Himpel, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Cherry Mui, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Chressie Himpel

Ian Lance Taylor voted and added 1 comment

Votes added by Ian Lance Taylor

Code-Review+2

1 comment

Patchset-level comments
Ian Lance Taylor . resolved

We don't have to add explicit raceacquire calls for other locks in the runtime. What is different about this one?

Ian Lance Taylor

Or, to put it another way, how can I reproduce the problem? "go test -race reflect" doesn't do it. I don't see any failures on the build dashboard.

Cherry Mui

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).

I'll see if I can work out a reproducer.

Thanks.

Ian Lance Taylor

I see, thanks.

Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Chressie Himpel
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
Gerrit-Change-Number: 742740
Gerrit-PatchSet: 2
Gerrit-Owner: Chressie Himpel <chre...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Chressie Himpel <chre...@google.com>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Comment-Date: Fri, 06 Feb 2026 22:33:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Cherry Mui <cher...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Cherry Mui (Gerrit)

unread,
Feb 6, 2026, 6:25:36 PM (9 hours ago) Feb 6
to Chressie Himpel, goph...@pubsubhelper.golang.org, Ian Lance Taylor, golang-co...@googlegroups.com
Attention needed from Chressie Himpel

Cherry Mui added 1 comment

Patchset-level comments
Ian Lance Taylor . resolved

We don't have to add explicit raceacquire calls for other locks in the runtime. What is different about this one?

Ian Lance Taylor

Or, to put it another way, how can I reproduce the problem? "go test -race reflect" doesn't do it. I don't see any failures on the build dashboard.

Cherry Mui

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).

I'll see if I can work out a reproducer.

Thanks.

Ian Lance Taylor

I see, thanks.

Cherry Mui

https://go.dev/play/p/7_kGki3MMJi is a reproducer, which fails in race mode.

Open in Gerrit

Related details

Attention is currently required from:
  • Chressie Himpel
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
Gerrit-Change-Number: 742740
Gerrit-PatchSet: 2
Gerrit-Owner: Chressie Himpel <chre...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Chressie Himpel <chre...@google.com>
Gerrit-Comment-Date: Fri, 06 Feb 2026 23:25:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Cherry Mui (Gerrit)

unread,
Feb 6, 2026, 6:31:09 PM (9 hours ago) Feb 6
to Chressie Himpel, goph...@pubsubhelper.golang.org, Ian Lance Taylor, golang-co...@googlegroups.com
Attention needed from Chressie Himpel

Cherry Mui voted and added 1 comment

Votes added by Cherry Mui

Code-Review+2

1 comment

Patchset-level comments
Ian Lance Taylor . unresolved

We don't have to add explicit raceacquire calls for other locks in the runtime. What is different about this one?

Ian Lance Taylor

Or, to put it another way, how can I reproduce the problem? "go test -race reflect" doesn't do it. I don't see any failures on the build dashboard.

Cherry Mui

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).

I'll see if I can work out a reproducer.

Thanks.

Ian Lance Taylor

I see, thanks.

Cherry Mui

https://go.dev/play/p/7_kGki3MMJi is a reproducer, which fails in race mode.

Cherry Mui

Let's add a test. Thanks.

It might need to be a standalone program, as moduleTypelinks is initialized only once. If it is already initialized in the sequential part of the program, it won't race.

Open in Gerrit

Related details

Attention is currently required from:
  • Chressie Himpel
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
Gerrit-Change-Number: 742740
Gerrit-PatchSet: 2
Gerrit-Owner: Chressie Himpel <chre...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Chressie Himpel <chre...@google.com>
Gerrit-Comment-Date: Fri, 06 Feb 2026 23:31:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Chressie Himpel (Gerrit)

unread,
2:15 AM (1 hour ago) 2:15 AM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Chressie Himpel and Ian Lance Taylor

Chressie Himpel uploaded new patchset

Chressie Himpel uploaded patch set #3 to this change.
Following approvals got outdated and were removed:
  • Code-Review: +2 by Cherry Mui, +2 by Ian Lance Taylor
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Chressie Himpel
  • Ian Lance Taylor
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
    Gerrit-Change-Number: 742740
    Gerrit-PatchSet: 3
    Gerrit-Owner: Chressie Himpel <chre...@google.com>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Attention: Chressie Himpel <chre...@google.com>
    Gerrit-Attention: Cherry Mui <cher...@google.com>
    unsatisfied_requirement
    open
    diffy

    Chressie Himpel (Gerrit)

    unread,
    2:19 AM (1 hour ago) 2:19 AM
    to goph...@pubsubhelper.golang.org, Cherry Mui, Ian Lance Taylor, golang-co...@googlegroups.com
    Attention needed from Cherry Mui and Ian Lance Taylor

    Chressie Himpel added 1 comment

    Patchset-level comments
    Ian Lance Taylor . resolved

    We don't have to add explicit raceacquire calls for other locks in the runtime. What is different about this one?

    Ian Lance Taylor

    Or, to put it another way, how can I reproduce the problem? "go test -race reflect" doesn't do it. I don't see any failures on the build dashboard.

    Cherry Mui

    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).

    I'll see if I can work out a reproducer.

    Thanks.

    Ian Lance Taylor

    I see, thanks.

    Cherry Mui

    https://go.dev/play/p/7_kGki3MMJi is a reproducer, which fails in race mode.

    Cherry Mui

    Let's add a test. Thanks.

    It might need to be a standalone program, as moduleTypelinks is initialized only once. If it is already initialized in the sequential part of the program, it won't race.

    Chressie Himpel

    Thanks! I added your explanation to the CL description and your reproducer as test/fixedbugs/bug519.go. I tested it with and without the instrumentation.

    Please submit, if you think it's in a proper state now. Thanks.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Cherry Mui
    • Ian Lance Taylor
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33
      Gerrit-Change-Number: 742740
      Gerrit-PatchSet: 3
      Gerrit-Owner: Chressie Himpel <chre...@google.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Attention: Cherry Mui <cher...@google.com>
      Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Comment-Date: Sat, 07 Feb 2026 07:19:23 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages