runtime: do not share underlying envs/argv array
Removes a potential data race between os.Setenv and runtime.GOROOT,
along with a bug where os.Setenv would only sometimes change the
value of runtime.GOROOT.
Change-Id: I7d2a905115c667ea6e73f349f3784a1d3e8f810d
Reviewed-on: https://go-review.googlesource.com/6611
Reviewed-by: Keith Randall <khr@golang.org>
diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go
index 6d32de2..5f0ca02 100644
--- a/src/runtime/runtime.go
+++ b/src/runtime/runtime.go
@@ -47,7 +47,7 @@
var argslice []string
//go:linkname syscall_runtime_envs syscall.runtime_envs
-func syscall_runtime_envs() []string { return envs }
+func syscall_runtime_envs() []string { return append([]string{}, envs...) }
//go:linkname os_runtime_args os.runtime_args
-func os_runtime_args() []string { return argslice }
+func os_runtime_args() []string { return append([]string{}, argslice...) }