-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: pollutes environment variables on Plan 9 #34971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
The change here almost certainly belongs in the |
Duplicate of #25234 |
Change https://golang.org/cl/202088 mentions this issue: |
Change https://golang.org/cl/236520 mentions this issue: |
gopherbot
pushed a commit
that referenced
this issue
Jun 19, 2020
In os.Getenv and os.Setenv, instead of directly reading and writing the Plan 9 environment device (which may be shared with other processes), use a local copy of environment variables cached at the start of execution. This gives the same semantics for Getenv and Setenv as on other operating systems which don't share the environment, making it more likely that Go programs (for example the build tests) will be portable to Plan 9. This doesn't preclude writing non-portable Plan 9 Go programs which make use of the shared environment semantics (for example to have a command which exports variable definitions to the parent shell). To do this, use ioutil.ReadFile("/env/"+key) and ioutil.WriteFile("/env/"+key, value, 0666) in place of os.Getenv(key) and os.Setenv(key, value) respectively. Note that CL 5599054 previously added env cacheing, citing efficiency as the reason. However it made the cache write-through, with Setenv changing the shared environment as well as the cache (so not consistent with Posix semantics), and Clearenv breaking the sharing of the environment between the calling thread and other threads (leading to unpredictable behaviour). Because of these inconsistencies (#8849), CL 158970045 removed the cacheing again. This CL restores cacheing but without write-through. The local cache is initialised at start of execution, manipulated by the standard functions in syscall/env_unix.go to ensure the same semantics, and exported only when exec'ing a new program. Fixes #34971 Fixes #25234 Fixes #19388 Updates #38772 Change-Id: I2dd15516d27414afaf99ea382f0e00be37a570c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/236520 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Fazlul Shahriar <fshahriar@gmail.com> Reviewed-by: David du Colombier <0intro@gmail.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
Working go command after testing
cmd/go
.What did you see instead?
Environment polluted with
$TMPDIR
, which breakscmd/go
.This is likely related to issue #25234.
@gopherbot please add labels OS-Plan9, NeedsFix
The text was updated successfully, but these errors were encountered: