]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix segfault in race instrumentation
authorDhananjay Nakrani <dhananjaynakrani@gmail.com>
Sun, 8 Jan 2017 07:42:23 +0000 (23:42 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 18 Oct 2017 16:46:18 +0000 (16:46 +0000)
Fixes #13265.

Change-Id: I792eb4ee26bef8a56e279e23f9802cb39019e0d0
Reviewed-on: https://go-review.googlesource.com/34929
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/walk.go
test/fixedbugs/issue13265.go [new file with mode: 0644]

index e973de968fc2447bf16fd5e538f2e8afc61c0c42..a597114252330d1644bd87c4128e1d7fe341c990 100644 (file)
@@ -2187,6 +2187,9 @@ func callnew(t *types.Type) *Node {
 }
 
 func iscallret(n *Node) bool {
+       if n == nil {
+               return false
+       }
        n = outervalue(n)
        return n.Op == OINDREGSP
 }
diff --git a/test/fixedbugs/issue13265.go b/test/fixedbugs/issue13265.go
new file mode 100644 (file)
index 0000000..3036ba7
--- /dev/null
@@ -0,0 +1,15 @@
+// errorcheck -0 -race
+
+// Copyright 2017 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.
+
+// Issue 13265: nil pointer deref.
+
+package p
+
+func f() {
+    var c chan chan chan int
+    for ; ; <-<-<-c {
+    }
+}