all: skip and fix various tests with -asan and -msan

First, skip all the allocation count tests.

In some cases this aligns with existing skips for -race, but in others
we've got new issues. These are debug modes, so some performance loss is
expected, and this is clearly no worse than today where the tests fail.

Next, skip internal linking and static linking tests for msan and asan.

With asan we get an explicit failure that neither are supported by the C
and/or Go compilers. With msan, we only get the Go compiler telling us
internal linking is unavailable. With static linking, we segfault
instead. Filed #70080 to track that.

Next, skip some malloc tests with asan that don't quite work because of
the redzone.

This is because of some sizeclass assumptions that get broken with the
redzone and the fact that the tiny allocator is effectively disabled
(again, due to the redzone).

Next, skip some runtime/pprof tests with asan, because of extra
allocations.

Next, skip some malloc tests with asan that also fail because of extra
allocations.

Next, fix up memstats accounting for arenas when asan is enabled. There
is a bug where more is added to the stats than subtracted. This also
simplifies the accounting a little.

Next, skip race tests with msan or asan enabled; they're mutually
incompatible.

Fixes #70054.
Fixes #64256.
Fixes #64257.
For #70079.
For #70080.

Change-Id: I99c02a0b9d621e44f1f918b307aa4a4944c3ec60
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15,gotip-linux-amd64-msan-clang15
Reviewed-on: https://go-review.googlesource.com/c/go/+/622855
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Michael Anthony Knyszek 2024-10-28 17:23:40 +00:00 committed by Michael Knyszek
parent 808da68c1c
commit 579eb79f62
22 changed files with 151 additions and 26 deletions

View file

@ -10,6 +10,7 @@ import (
"flag"
"fmt"
"go/token"
"internal/asan"
"internal/goarch"
"internal/goexperiment"
"internal/testenv"
@ -1278,6 +1279,9 @@ func TestDeepEqualAllocs(t *testing.T) {
if goexperiment.SwissMap {
t.Skipf("Maps on stack not yet implemented")
}
if asan.Enabled {
t.Skip("test allocates more with -asan; see #70079")
}
for _, tt := range deepEqualPerfTests {
t.Run(ValueOf(tt.x).Type().String(), func(t *testing.T) {
@ -7353,6 +7357,9 @@ func TestPtrToMethods(t *testing.T) {
}
func TestMapAlloc(t *testing.T) {
if asan.Enabled {
t.Skip("test allocates more with -asan; see #70079")
}
m := ValueOf(make(map[int]int, 10))
k := ValueOf(5)
v := ValueOf(7)
@ -7383,6 +7390,9 @@ func TestMapAlloc(t *testing.T) {
}
func TestChanAlloc(t *testing.T) {
if asan.Enabled {
t.Skip("test allocates more with -asan; see #70079")
}
// Note: for a chan int, the return Value must be allocated, so we
// use a chan *int instead.
c := ValueOf(make(chan *int, 1))
@ -7745,11 +7755,14 @@ func TestMapIterReset(t *testing.T) {
}
// Reset should not allocate.
//
// Except with -asan, where there are additional allocations.
// See #70079.
n := int(testing.AllocsPerRun(10, func() {
iter.Reset(ValueOf(m2))
iter.Reset(Value{})
}))
if n > 0 {
if !asan.Enabled && n > 0 {
t.Errorf("MapIter.Reset allocated %d times", n)
}
}