aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorMauri de Souza Meneguzzo <mauri870@gmail.com>2023-12-13 19:58:23 +0000
committerGopher Robot <gobot@golang.org>2023-12-18 19:22:04 +0000
commit2acbdd086d4660ae5e4adc429858df4758d675e3 (patch)
treecb1d409b9c1b129c493b76c1a9ba4cb2c494239e /src/cmd
parenta7097243e462802f3055da9f843013e450a75092 (diff)
downloadgo-2acbdd086d4660ae5e4adc429858df4758d675e3.tar.xz
cmd/cgo/internal/testsanitizers: fix msan test failing with clang >= 16
Clang 16 introduced a more aggressive behavior regarding uninitialized memory in the memory sanitizer. The new option -fsanitize-memory-param-retval is enabled by default and makes the test msan8 fail, since it uses an uninitialized variable on purpose. Disable this behavior if we are running with clang 16+. Fixes #64616 Change-Id: If366f978bef984ea73f6ae958f24c8fce99b59fe GitHub-Last-Rev: 60bd64a8fb24a552fce23fb2b43a75e92443e039 GitHub-Pull-Request: golang/go#64691 Reviewed-on: https://go-review.googlesource.com/c/go/+/549297 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/cgo/internal/testsanitizers/msan_test.go5
-rw-r--r--src/cmd/cgo/internal/testsanitizers/testdata/msan8.go7
2 files changed, 11 insertions, 1 deletions
diff --git a/src/cmd/cgo/internal/testsanitizers/msan_test.go b/src/cmd/cgo/internal/testsanitizers/msan_test.go
index 83d66f6660..c534b72442 100644
--- a/src/cmd/cgo/internal/testsanitizers/msan_test.go
+++ b/src/cmd/cgo/internal/testsanitizers/msan_test.go
@@ -71,7 +71,10 @@ func TestMSAN(t *testing.T) {
defer dir.RemoveAll(t)
outPath := dir.Join(name)
- mustRun(t, config.goCmdWithExperiments("build", []string{"-o", outPath, srcPath(tc.src)}, tc.experiments))
+ buildcmd := config.goCmdWithExperiments("build", []string{"-o", outPath, srcPath(tc.src)}, tc.experiments)
+ // allow tests to define -f flags in CGO_CFLAGS
+ replaceEnv(buildcmd, "CGO_CFLAGS_ALLOW", "-f.*")
+ mustRun(t, buildcmd)
cmd := hangProneCmd(outPath)
if tc.wantErr {
diff --git a/src/cmd/cgo/internal/testsanitizers/testdata/msan8.go b/src/cmd/cgo/internal/testsanitizers/testdata/msan8.go
index 1cb5c5677f..e79d343cc7 100644
--- a/src/cmd/cgo/internal/testsanitizers/testdata/msan8.go
+++ b/src/cmd/cgo/internal/testsanitizers/testdata/msan8.go
@@ -5,6 +5,13 @@
package main
/*
+// For clang >= 16, uninitialized memory is more aggressively reported.
+// Restore the old behavior for this particular test as it relies on
+// uninitialized variables. See #64616
+#if __clang_major__ >= 16
+#cgo CFLAGS: -fno-sanitize-memory-param-retval
+#endif
+
#include <pthread.h>
#include <signal.h>
#include <stdint.h>