From: Josh Bleecher Snyder Date: Fri, 24 Mar 2017 23:15:10 +0000 (-0700) Subject: cmd/compile: prevent modification of ONAME/OLITERAL/OTYPES nodes in walkexpr X-Git-Tag: go1.9beta1~977 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ecc6a81617477ddfa961f44e309707a4f864104a;p=gostls13.git cmd/compile: prevent modification of ONAME/OLITERAL/OTYPES nodes in walkexpr ONAME, OLITERAL, and OTYPE nodes can be shared between functions. In a concurrent backend, such nodes might be walked concurrently with being read in other functions. Arrange for them to be unmodified by walk. This is a follow-up to CL 38609. Passes toolstash-check. Updates #15756 Change-Id: I03ff1d2c0ad81dafac3fd55caa218939cf7c0565 Reviewed-on: https://go-review.googlesource.com/38655 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go index 3885ca32be..f98076ac05 100644 --- a/src/cmd/compile/internal/gc/subr.go +++ b/src/cmd/compile/internal/gc/subr.go @@ -1181,7 +1181,11 @@ func updateHasCall(n *Node) { } switch n.Op { - case OLITERAL, ONAME: + case OLITERAL, ONAME, OTYPE: + if b || n.HasCall() { + Fatalf("OLITERAL/ONAME/OTYPE should never have calls: %+v", n) + } + return case OAS: if needwritebarrier(n.Left) { b = true diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index 0528949081..c7e35097b8 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -498,7 +498,10 @@ opswitch: Dump("walk", n) Fatalf("walkexpr: switch 1 unknown op %+S", n) - case OTYPE, ONONAME, OINDREGSP, OEMPTY, OGETG: + case ONONAME, OINDREGSP, OEMPTY, OGETG: + + case OTYPE, ONAME, OLITERAL: + // TODO(mdempsky): Just return n; see discussion on CL 38655. case ONOT, OMINUS, OPLUS, OCOM, OREAL, OIMAG, ODOTMETH, ODOTINTER, OIND, OSPTR, OITAB, OIDATA, ODOTTYPE, ODOTTYPE2, OADDR: @@ -593,7 +596,7 @@ opswitch: case ORECOVER: n = mkcall("gorecover", n.Type, init, nod(OADDR, nodfp, nil)) - case OLITERAL, OCLOSUREVAR, OCFUNC, ONAME: + case OCLOSUREVAR, OCFUNC: n.SetAddable(true) case OCALLINTER: