[go] cmd/link: align covctrs symbol

4 views
Skip to first unread message

Keith Randall (Gerrit)

unread,
Jan 2, 2026, 5:16:15 PMJan 2
to Cherry Mui, goph...@pubsubhelper.golang.org, Keith Randall, golang-co...@googlegroups.com
Attention needed from Cherry Mui

Keith Randall has uploaded the change for review

Keith Randall would like Cherry Mui to review this change.

Commit message

cmd/link: align covctrs symbol

If we start the covctrs blob at an odd alignment, then covctrs will
not be correctly aligned. Each individual entry is aligned properly,
but the start marker may be before any padding inserted to enforce
that alignment.

Fixes #58936
Change-Id: I802fbe40eacfa5a3c8c4864e078b0e078da956d5

Change diff

diff --git a/src/cmd/cover/cover_test.go b/src/cmd/cover/cover_test.go
index 431c056..a5e5bdd 100644
--- a/src/cmd/cover/cover_test.go
+++ b/src/cmd/cover/cover_test.go
@@ -638,3 +638,12 @@
t.Errorf("unexpected success; want failure due to newline in file path")
}
}
+
+func TestAlignment(t *testing.T) {
+ // Test that cover data structures are aligned appropriately. See issue 58936.
+ testenv.MustHaveGoRun(t)
+ t.Parallel()
+
+ cmd := testenv.Command(t, testenv.GoToolPath(t), "test", "-cover", filepath.Join(testdata, "align.go"), filepath.Join(testdata, "align_test.go"))
+ run(cmd, t)
+}
diff --git a/src/cmd/cover/testdata/align.go b/src/cmd/cover/testdata/align.go
new file mode 100644
index 0000000..2e8a453
--- /dev/null
+++ b/src/cmd/cover/testdata/align.go
@@ -0,0 +1,11 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+var badSlice [8265]byte
+
+func init() {
+ badSlice[0] = 4
+}
diff --git a/src/cmd/cover/testdata/align_test.go b/src/cmd/cover/testdata/align_test.go
new file mode 100644
index 0000000..e908c5a
--- /dev/null
+++ b/src/cmd/cover/testdata/align_test.go
@@ -0,0 +1,10 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+import "testing"
+
+func TestFoo(t *testing.T) {
+}
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go
index 5b6dabb..a1d36ae 100644
--- a/src/cmd/link/internal/ld/data.go
+++ b/src/cmd/link/internal/ld/data.go
@@ -2049,6 +2049,13 @@
ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.covctrs", 0), sect)
ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.ecovctrs", 0), sect)

+ // If we started this blob at an odd alignment, then covctrs will
+ // not be correctly aligned. Each individual entry is aligned properly,
+ // but the start marker may be before any padding inserted to enforce
+ // that alignment. Fix that here. See issue 58936.
+ covCounterDataStartOff += covCounterDataLen % 4
+ covCounterDataLen -= covCounterDataLen % 4
+
// Coverage instrumentation counters for libfuzzer.
if len(state.data[sym.SLIBFUZZER_8BIT_COUNTER]) > 0 {
sect := state.allocateNamedSectionAndAssignSyms(&Segdata, ".go.fuzzcntrs", sym.SLIBFUZZER_8BIT_COUNTER, sym.Sxxx, 06)

Change information

Files:
  • M src/cmd/cover/cover_test.go
  • A src/cmd/cover/testdata/align.go
  • A src/cmd/cover/testdata/align_test.go
  • M src/cmd/link/internal/ld/data.go
Change size: S
Delta: 4 files changed, 37 insertions(+), 0 deletions(-)
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: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I802fbe40eacfa5a3c8c4864e078b0e078da956d5
Gerrit-Change-Number: 733740
Gerrit-PatchSet: 1
Gerrit-Owner: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Cherry Mui (Gerrit)

unread,
Jan 2, 2026, 7:40:01 PMJan 2
to Keith Randall, goph...@pubsubhelper.golang.org, Go LUCI, Than McIntosh, golang-co...@googlegroups.com
Attention needed from Keith Randall and Than McIntosh

Cherry Mui voted and added 1 comment

Votes added by Cherry Mui

Code-Review+2

1 comment

File src/cmd/link/internal/ld/data.go
Line 2056, Patchset 1 (Latest): covCounterDataStartOff += covCounterDataLen % 4
Cherry Mui . unresolved

Perhaps use `Rnd` helper function, and just combine to line 2046. (Rnd takes int64. Conversion back and forth seems unfortunate. Maybe we can make Rnd generic now.)

Open in Gerrit

Related details

Attention is currently required from:
  • Keith Randall
  • Than McIntosh
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement 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: I802fbe40eacfa5a3c8c4864e078b0e078da956d5
Gerrit-Change-Number: 733740
Gerrit-PatchSet: 1
Gerrit-Owner: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Than McIntosh <th...@golang.org>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: Than McIntosh <th...@golang.org>
Gerrit-Comment-Date: Sat, 03 Jan 2026 00:39:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Keith Randall (Gerrit)

unread,
Jan 2, 2026, 11:22:29 PMJan 2
to Keith Randall, goph...@pubsubhelper.golang.org, Cherry Mui, Go LUCI, Than McIntosh, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Than McIntosh

Keith Randall added 1 comment

File src/cmd/link/internal/ld/data.go
Line 2056, Patchset 1 (Latest): covCounterDataStartOff += covCounterDataLen % 4
Cherry Mui . unresolved

Perhaps use `Rnd` helper function, and just combine to line 2046. (Rnd takes int64. Conversion back and forth seems unfortunate. Maybe we can make Rnd generic now.)

Keith Randall

I worry a bit about the common case when there are no cover counters.
Then we're potentially rounding up covctrs/ecovctrs past the end of the section?

The CL as is at least does nothing if there are no cover counters.

Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Than McIntosh
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement 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: I802fbe40eacfa5a3c8c4864e078b0e078da956d5
Gerrit-Change-Number: 733740
Gerrit-PatchSet: 1
Gerrit-Owner: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Than McIntosh <th...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Attention: Than McIntosh <th...@golang.org>
Gerrit-Comment-Date: Sat, 03 Jan 2026 04:22:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Cherry Mui <cher...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Keith Randall (Gerrit)

unread,
Feb 6, 2026, 6:22:15 PM (9 hours ago) Feb 6
to Keith Randall, goph...@pubsubhelper.golang.org, Cherry Mui, Go LUCI, Than McIntosh, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Than McIntosh

Keith Randall added 1 comment

File src/cmd/link/internal/ld/data.go
Line 2056, Patchset 1 (Latest): covCounterDataStartOff += covCounterDataLen % 4
Cherry Mui . resolved

Perhaps use `Rnd` helper function, and just combine to line 2046. (Rnd takes int64. Conversion back and forth seems unfortunate. Maybe we can make Rnd generic now.)

Keith Randall

I worry a bit about the common case when there are no cover counters.
Then we're potentially rounding up covctrs/ecovctrs past the end of the section?

The CL as is at least does nothing if there are no cover counters.

Keith Randall

Acknowledged

Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Than McIntosh
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement 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: I802fbe40eacfa5a3c8c4864e078b0e078da956d5
Gerrit-Change-Number: 733740
Gerrit-PatchSet: 1
Gerrit-Owner: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Than McIntosh <th...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Attention: Than McIntosh <th...@golang.org>
Gerrit-Comment-Date: Fri, 06 Feb 2026 23:22:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Keith Randall <k...@golang.org>
Comment-In-Reply-To: Cherry Mui <cher...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Keith Randall (Gerrit)

unread,
Feb 6, 2026, 6:22:32 PM (9 hours ago) Feb 6
to Keith Randall, goph...@pubsubhelper.golang.org, Cherry Mui, Go LUCI, Than McIntosh, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Keith Randall and Than McIntosh

Keith Randall voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Keith Randall
  • Than McIntosh
Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement 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: I802fbe40eacfa5a3c8c4864e078b0e078da956d5
    Gerrit-Change-Number: 733740
    Gerrit-PatchSet: 1
    Gerrit-Owner: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Keith Randall <k...@google.com>
    Gerrit-Reviewer: Than McIntosh <th...@golang.org>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: Cherry Mui <cher...@google.com>
    Gerrit-Attention: Than McIntosh <th...@golang.org>
    Gerrit-Comment-Date: Fri, 06 Feb 2026 23:22:29 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Keith Randall (Gerrit)

    unread,
    Feb 6, 2026, 6:22:42 PM (9 hours ago) Feb 6
    to Keith Randall, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Keith Randall, Cherry Mui, Go LUCI, Than McIntosh, golang-co...@googlegroups.com

    Keith Randall submitted the change

    Change information

    Commit message:
    cmd/link: align covctrs symbol

    If we start the covctrs blob at an odd alignment, then covctrs will
    not be correctly aligned. Each individual entry is aligned properly,
    but the start marker may be before any padding inserted to enforce
    that alignment.

    Fixes #58936
    Change-Id: I802fbe40eacfa5a3c8c4864e078b0e078da956d5
    Reviewed-by: Cherry Mui <cher...@google.com>
    Reviewed-by: Keith Randall <k...@google.com>
    Files:
    • M src/cmd/cover/cover_test.go
    • A src/cmd/cover/testdata/align.go
    • A src/cmd/cover/testdata/align_test.go
    • M src/cmd/link/internal/ld/data.go
    Change size: S
    Delta: 4 files changed, 37 insertions(+), 0 deletions(-)
    Branch: refs/heads/master
    Submit Requirements:
    • requirement satisfiedCode-Review: +2 by Cherry Mui, +1 by Keith Randall
    • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I802fbe40eacfa5a3c8c4864e078b0e078da956d5
    Gerrit-Change-Number: 733740
    Gerrit-PatchSet: 2
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages