From 08831b150c60b96045a614f3d35abf631ddd4b4a Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Tue, 16 Oct 2018 16:11:59 +0200 Subject: [PATCH] cmd/compile: avoid collisions between statictmps and user vars Avoid name collisions between autogenerated statictmp variables and user defined global variables. Fixes #25113 Change-Id: I023eb42a5c2bd2f5352b046d33363faed87084dc Reviewed-on: https://go-review.googlesource.com/c/142497 Reviewed-by: Josh Bleecher Snyder Reviewed-by: Emmanuel Odeke Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/sinit.go | 2 +- src/cmd/compile/internal/ssa/writebarrier.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/gc/sinit.go b/src/cmd/compile/internal/gc/sinit.go index de0298b746..efdaf1c3c5 100644 --- a/src/cmd/compile/internal/gc/sinit.go +++ b/src/cmd/compile/internal/gc/sinit.go @@ -568,7 +568,7 @@ var statuniqgen int // name generator for static temps // returned node for readonly nodes. func staticname(t *types.Type) *Node { // Don't use lookupN; it interns the resulting string, but these are all unique. - n := newname(lookup(fmt.Sprintf("statictmp_%d", statuniqgen))) + n := newname(lookup(fmt.Sprintf(".stmp_%d", statuniqgen))) statuniqgen++ addvar(n, t, PEXTERN) return n diff --git a/src/cmd/compile/internal/ssa/writebarrier.go b/src/cmd/compile/internal/ssa/writebarrier.go index 1024ab25ab..1f40927951 100644 --- a/src/cmd/compile/internal/ssa/writebarrier.go +++ b/src/cmd/compile/internal/ssa/writebarrier.go @@ -439,7 +439,7 @@ func IsSanitizerSafeAddr(v *Value) bool { // test sym.Type==objabi.SRODATA, but we don't // initialize sym.Type until after function // compilation. - if strings.HasPrefix(sym.Name, `"".statictmp_`) { + if strings.HasPrefix(sym.Name, `""..stmp_`) { return true } } -- 2.50.0