1
2
3
4
5
6
7
8
9
10
11 package main
12
13 import (
14 "bytes"
15 "regexp"
16 "runtime"
17 "strconv"
18 )
19
20 func main() {
21 buf1 := make([]byte, 1000)
22 buf2 := make([]byte, 1000)
23
24 runtime.Stack(buf1, false)
25 n := runtime.Stack(buf2, false)
26
27 buf1 = buf1[:bytes.IndexByte(buf1, 0)]
28 buf2 = buf2[:n]
29
30 re := regexp.MustCompile(`(?m)^main\.main\(\)\n.*/issue7690.go:([0-9]+)`)
31 m1 := re.FindStringSubmatch(string(buf1))
32 if m1 == nil {
33 println("BUG: cannot find main.main in first trace")
34 return
35 }
36 m2 := re.FindStringSubmatch(string(buf2))
37 if m2 == nil {
38 println("BUG: cannot find main.main in second trace")
39 return
40 }
41
42 n1, _ := strconv.Atoi(m1[1])
43 n2, _ := strconv.Atoi(m2[1])
44 if n1+1 != n2 {
45 println("BUG: expect runtime.Stack on back to back lines, have", n1, n2)
46 println(string(buf1))
47 println(string(buf2))
48 }
49 }
50
View as plain text