Skip to content
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

syscall: Clearenv is racy on Plan9 #35083

Closed
fhs opened this issue Oct 22, 2019 · 1 comment
Closed

syscall: Clearenv is racy on Plan9 #35083

fhs opened this issue Oct 22, 2019 · 1 comment

Comments

@fhs
Copy link
Contributor

@fhs fhs commented Oct 22, 2019

What version of Go are you using (go version)?

$ go version
go version devel +master Tue Oct 22 13:09:23 EDT 2019 plan9/386

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE='on'
GOARCH='386'
GOBIN=''
GOCACHE='/usr/fhs/lib/cache/go-build'
GOENV='/usr/fhs/lib/go/env'
GOEXE=''
GOFLAGS=''
GOHOSTARCH='386'
GOHOSTOS='plan9'
GONOPROXY=''
GONOSUMDB=''
GOOS='plan9'
GOPATH='/home/fhs/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/big/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLDIR='/home/big/go/pkg/tool/plan9_386'
GCCGO='gccgo'
GO386='sse2'
AR='ar'
CC='8c'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/home/big/go/src/go.mod'
CGO_CFLAGS='-g -O2'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-g -O2'
CGO_FFLAGS='-g -O2'
CGO_LDFLAGS='-g -O2'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m32 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build454216994=/tmp/go-build -gno-record-gcc-switches'

What did you do?

cpu% cd src/os
cpu% go test -run Clearenv -count 100000

What did you expect to see?

No test failure

What did you see instead?

--- FAIL: TestClearenv (0.02s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.02s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.02s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.02s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.01s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.01s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.00s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.00s)
    env_test.go:149: Clearenv() didn't clear $GO_TEST_CLEARENV, remained with value "1"
--- FAIL: TestClearenv (0.00s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.00s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.00s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.00s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.00s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.00s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.00s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
--- FAIL: TestClearenv (0.00s)
    env_test.go:145: Setenv("GO_TEST_CLEARENV", "1") didn't set $GO_TEST_CLEARENV
FAIL
exit status: 'os.test 25721: 1'
FAIL	os	145.298s

Existence of a race in env tests was originally reported in issue #25234, but it incorrectly assumed it was due to shared /env. Instead, the race seems to be in the Plan 9 kernel, between rfork(RFCENVG) and access to /env.

I propose replacing rfork(RFCENVG) (which creates a new env group) with removal of all environment variables in the current env group. I'll send a CL soon.

@gopherbot Please add label OS-Plan9, NeedsFix

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 22, 2019

Change https://golang.org/cl/202657 mentions this issue: syscall: fix Clearenv race on Plan 9

@gopherbot gopherbot closed this in b284dac Oct 23, 2019
@golang golang locked and limited conversation to collaborators Oct 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.