aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-08-12 12:18:51 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-08-12 12:43:12 -0700
commita64ab8d3ecb38e10007e136edc9dc3abde873e1e (patch)
tree8700291a327c4ae34dd3fea11c5087e4f7566cb1 /misc
parent677dfe5ad677d7072ffd69963c407a8945e94ec5 (diff)
parent46fd547d899286982971474b329d7a95da4f2a6b (diff)
downloadgo-a64ab8d3ecb38e10007e136edc9dc3abde873e1e.tar.gz
go-a64ab8d3ecb38e10007e136edc9dc3abde873e1e.zip
[dev.typeparams] all: merge master (46fd547) into dev.typeparams
Conflicts: - src/go/types/check_test.go CL 324730 on dev.typeparams changed the directory paths in TestCheck, TestExamples, and TestFixedbugs and renamed checkFiles to testFiles; whereas CL 337529 on master added a new test case just above them and that used checkFiles. Merge List: + 2021-08-12 46fd547d89 internal/goversion: update Version to 1.18 + 2021-08-12 5805efc78e doc/go1.17: remove draft notice + 2021-08-12 39634e7dae CONTRIBUTORS: update for the Go 1.17 release + 2021-08-12 095bb790e1 os/exec: re-enable LookPathTest/16 + 2021-08-11 dea23e9ca8 src/make.*: make --no-clean flag a no-op that prints a warning + 2021-08-11 d4c0ed26ac doc/go1.17: linker passes -I to extld as -Wl,--dynamic-linker + 2021-08-10 1f9c9d8530 doc: use "high address/low address" instead of "top/bottom" + 2021-08-09 f1dce319ff cmd/go: with -mod=vendor, don't panic if there are duplicate requirements + 2021-08-09 7aeaad5c86 runtime/cgo: when using msan explicitly unpoison cgoCallers + 2021-08-08 507cc341ec doc: add example for conversion from slice expressions to array ptr + 2021-08-07 891547e2d4 doc/go1.17: fix a typo introduced in CL 335135 + 2021-08-06 8eaf4d16bc make.bash: do not overwrite GO_LDSO if already set + 2021-08-06 63b968f4f8 doc/go1.17: clarify Modules changes + 2021-08-06 70546f6404 runtime: allow arm64 SEH to be called if illegal instruction + 2021-08-05 fd45e267c2 runtime: warn that KeepAlive is not an unsafe.Pointer workaround + 2021-08-04 6e738868a7 net/http: speed up and deflake TestCancelRequestWhenSharingConnection + 2021-08-02 8a7ee4c51e io/fs: don't use absolute path in DirEntry.Name doc + 2021-07-31 b8ca6e59ed all: gofmt + 2021-07-30 b7a85e0003 net/http/httputil: close incoming ReverseProxy request body + 2021-07-29 70fd4e47d7 runtime: avoid possible preemption when returning from Go to C + 2021-07-28 9eee0ed439 cmd/go: fix go.mod file name printed in error messages for replacements + 2021-07-28 b39e0f461c runtime: don't crash on nil pointers in checkptrAlignment + 2021-07-27 7cd10c1149 cmd/go: use .mod instead of .zip to determine if version has go.mod file + 2021-07-27 c8cf0f74e4 cmd/go: add missing flag in UsageLine + 2021-07-27 7ba8e796c9 testing: clarify T.Name returns a distinct name of the running test + 2021-07-27 33ff155970 go/types: preserve untyped constants on the RHS of a shift expression + 2021-07-26 840e583ff3 runtime: correct variable name in comment + 2021-07-26 bfbb288574 runtime: remove adjustTimers counter + 2021-07-26 9c81fd53b3 cmd/vet: add missing copyright header Change-Id: Ia80604d24c6f4205265683024e3100769cf32065
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/testsanitizers/msan_test.go1
-rw-r--r--misc/cgo/testsanitizers/testdata/msan8.go109
2 files changed, 110 insertions, 0 deletions
diff --git a/misc/cgo/testsanitizers/msan_test.go b/misc/cgo/testsanitizers/msan_test.go
index 2a3494fbfc..5ee9947a58 100644
--- a/misc/cgo/testsanitizers/msan_test.go
+++ b/misc/cgo/testsanitizers/msan_test.go
@@ -42,6 +42,7 @@ func TestMSAN(t *testing.T) {
{src: "msan5.go"},
{src: "msan6.go"},
{src: "msan7.go"},
+ {src: "msan8.go"},
{src: "msan_fail.go", wantErr: true},
}
for _, tc := range cases {
diff --git a/misc/cgo/testsanitizers/testdata/msan8.go b/misc/cgo/testsanitizers/testdata/msan8.go
new file mode 100644
index 0000000000..1cb5c5677f
--- /dev/null
+++ b/misc/cgo/testsanitizers/testdata/msan8.go
@@ -0,0 +1,109 @@
+// Copyright 2021 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 main
+
+/*
+#include <pthread.h>
+#include <signal.h>
+#include <stdint.h>
+
+#include <sanitizer/msan_interface.h>
+
+// cgoTracebackArg is the type of the argument passed to msanGoTraceback.
+struct cgoTracebackArg {
+ uintptr_t context;
+ uintptr_t sigContext;
+ uintptr_t* buf;
+ uintptr_t max;
+};
+
+// msanGoTraceback is registered as the cgo traceback function.
+// This will be called when a signal occurs.
+void msanGoTraceback(void* parg) {
+ struct cgoTracebackArg* arg = (struct cgoTracebackArg*)(parg);
+ arg->buf[0] = 0;
+}
+
+// msanGoWait will be called with all registers undefined as far as
+// msan is concerned. It just waits for a signal.
+// Because the registers are msan-undefined, the signal handler will
+// be invoked with all registers msan-undefined.
+__attribute__((noinline))
+void msanGoWait(unsigned long a1, unsigned long a2, unsigned long a3, unsigned long a4, unsigned long a5, unsigned long a6) {
+ sigset_t mask;
+
+ sigemptyset(&mask);
+ sigsuspend(&mask);
+}
+
+// msanGoSignalThread is the thread ID of the msanGoLoop thread.
+static pthread_t msanGoSignalThread;
+
+// msanGoSignalThreadSet is used to record that msanGoSignalThread
+// has been initialized. This is accessed atomically.
+static int32_t msanGoSignalThreadSet;
+
+// uninit is explicitly poisoned, so that we can make all registers
+// undefined by calling msanGoWait.
+static unsigned long uninit;
+
+// msanGoLoop loops calling msanGoWait, with the arguments passed
+// such that msan thinks that they are undefined. msan permits
+// undefined values to be used as long as they are not used to
+// for conditionals or for memory access.
+void msanGoLoop() {
+ int i;
+
+ msanGoSignalThread = pthread_self();
+ __atomic_store_n(&msanGoSignalThreadSet, 1, __ATOMIC_SEQ_CST);
+
+ // Force uninit to be undefined for msan.
+ __msan_poison(&uninit, sizeof uninit);
+ for (i = 0; i < 100; i++) {
+ msanGoWait(uninit, uninit, uninit, uninit, uninit, uninit);
+ }
+}
+
+// msanGoReady returns whether msanGoSignalThread is set.
+int msanGoReady() {
+ return __atomic_load_n(&msanGoSignalThreadSet, __ATOMIC_SEQ_CST) != 0;
+}
+
+// msanGoSendSignal sends a signal to the msanGoLoop thread.
+void msanGoSendSignal() {
+ pthread_kill(msanGoSignalThread, SIGWINCH);
+}
+*/
+import "C"
+
+import (
+ "runtime"
+ "time"
+)
+
+func main() {
+ runtime.SetCgoTraceback(0, C.msanGoTraceback, nil, nil)
+
+ c := make(chan bool)
+ go func() {
+ defer func() { c <- true }()
+ C.msanGoLoop()
+ }()
+
+ for C.msanGoReady() == 0 {
+ time.Sleep(time.Microsecond)
+ }
+
+loop:
+ for {
+ select {
+ case <-c:
+ break loop
+ default:
+ C.msanGoSendSignal()
+ time.Sleep(time.Microsecond)
+ }
+ }
+}