Skip to content

Commit d5cfcc7

Browse files
committed
add test case for issue #34391
1 parent 843fec1 commit d5cfcc7

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

src/runtime/crash_test.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,18 @@ func buildTestProg(t *testing.T, binary string, flags ...string) (string, error)
143143
return exe, nil
144144
}
145145

146-
func TestVDSO(t *testing.T) {
146+
func TestSIGPROFInVDSO(t *testing.T) {
147147
t.Parallel()
148-
output := runTestProg(t, "testprog", "SignalInVDSO")
148+
output := runTestProg(t, "testprog", "SIGPROFInVDSO")
149+
want := "success\n"
150+
if output != want {
151+
t.Fatalf("output:\n%s\n\nwanted:\n%s", output, want)
152+
}
153+
}
154+
155+
func TestSIGUSR1InVDSO(t *testing.T) {
156+
t.Parallel()
157+
output := runTestProg(t, "testprog", "SIGUSR1InVDSO")
149158
want := "success\n"
150159
if output != want {
151160
t.Fatalf("output:\n%s\n\nwanted:\n%s", output, want)

src/runtime/testdata/testprog/vdso.go

+31-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// Invoke signal hander in the VDSO context (see issue 32912).
5+
// Invoke signal hander in the VDSO context.
6+
// See issue 32912 and 34391.
67

78
package main
89

@@ -11,14 +12,16 @@ import (
1112
"io/ioutil"
1213
"os"
1314
"runtime/pprof"
15+
"syscall"
1416
"time"
1517
)
1618

1719
func init() {
18-
register("SignalInVDSO", signalInVDSO)
20+
register("SIGPROFInVDSO", signalSIGPROFInVDSO)
21+
register("SIGUSR1InVDSO", signalSIGUSR1InVDSO)
1922
}
2023

21-
func signalInVDSO() {
24+
func signalSIGPROFInVDSO() {
2225
f, err := ioutil.TempFile("", "timeprofnow")
2326
if err != nil {
2427
fmt.Fprintln(os.Stderr, err)
@@ -53,3 +56,28 @@ func signalInVDSO() {
5356

5457
fmt.Println("success")
5558
}
59+
60+
func signalSIGUSR1InVDSO() {
61+
done := make(chan struct {})
62+
63+
p, _ := os.FindProcess(os.Getpid())
64+
go func() {
65+
for {
66+
p.Signal(syscall.SIGUSR1)
67+
select {
68+
case <- done:
69+
return
70+
default:
71+
}
72+
}
73+
}()
74+
75+
t0 := time.Now()
76+
t1 := t0
77+
for t1.Sub(t0) < time.Second {
78+
t1 = time.Now()
79+
}
80+
close(done)
81+
82+
fmt.Println("success")
83+
}

0 commit comments

Comments
 (0)