]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: mark OpenBSD raise function nosplit
authorIan Lance Taylor <iant@golang.org>
Mon, 6 Jul 2020 21:23:26 +0000 (14:23 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 8 Jul 2020 19:50:20 +0000 (19:50 +0000)
It is called by the signal handler before switching to gsignal
(sigtrampgo -> sigfwdgo -> dieFromSignal -> raise)
which means that it must not split the stack.

All other instances of raise are already marked nosplit.

Fixes #40076

Change-Id: I4794491331af48c46d0d8ebc82d34c6483f0e6cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/241121
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/os/pipe_test.go
src/runtime/os_openbsd.go

index 2e93e3946af84d7371676370e9c647f251dc48df..429bd813c20dab19147aa8b64b0f94c7acd0350d 100644 (file)
@@ -104,6 +104,25 @@ func TestStdPipe(t *testing.T) {
                        }
                }
        }
+
+       // Test redirecting stdout but not stderr.  Issue 40076.
+       cmd := osexec.Command(os.Args[0], "-test.run", "TestStdPipeHelper")
+       cmd.Stdout = w
+       var stderr bytes.Buffer
+       cmd.Stderr = &stderr
+       cmd.Env = append(os.Environ(), "GO_TEST_STD_PIPE_HELPER=1")
+       if err := cmd.Run(); err == nil {
+               t.Errorf("unexpected success of write to closed stdout")
+       } else if ee, ok := err.(*osexec.ExitError); !ok {
+               t.Errorf("unexpected exec error type %T: %v", err, err)
+       } else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok {
+               t.Errorf("unexpected wait status type %T: %v", ee.Sys(), ee.Sys())
+       } else if !ws.Signaled() || ws.Signal() != syscall.SIGPIPE {
+               t.Errorf("unexpected exit status %v for write to closed stdout", err)
+       }
+       if output := stderr.Bytes(); len(output) > 0 {
+               t.Errorf("unexpected output on stderr: %s", output)
+       }
 }
 
 // This is a helper for TestStdPipe. It's not a test in itself.
index b486b83688bc7d202e4c48c354d66b61687d59e8..cd3565df5b4b04a313fe8dbce50333ef3b187ec5 100644 (file)
@@ -340,6 +340,7 @@ func osStackRemap(s *mspan, flags int32) {
        }
 }
 
+//go:nosplit
 func raise(sig uint32) {
        thrkill(getthrid(), int(sig))
 }