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)
+}
--- /dev/null
+// 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
+}
--- /dev/null
+// 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) {
+}
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)