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

os/user: TestCredentialNoSetGroups failed #56942

Closed
YoshikiShibata opened this issue Nov 25, 2022 · 8 comments
Closed

os/user: TestCredentialNoSetGroups failed #56942

YoshikiShibata opened this issue Nov 25, 2022 · 8 comments
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@YoshikiShibata
Copy link

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

$ go version
go version devel go1.20-d5de62df15 Thu Nov 24 06:48:07 2022 +0000 darwin/arm64

Does this issue reproduce with the latest release?

N/A

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/yoshikishibata/Library/Caches/go-build"
GOENV="/Users/yoshikishibata/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/yoshikishibata/gocode/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/yoshikishibata/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/yoshikishibata/tools/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/yoshikishibata/tools/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="devel go1.20-d5de62df15 Thu Nov 24 06:48:07 2022 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/fs/3c1rlryd2v3_z5m04g3lnd580000gn/T/go-build3727885018=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version devel go1.20-d5de62df15 Thu Nov 24 06:48:07 2022 +0000 darwin/arm64
GOROOT/bin/go tool compile -V: compile version devel go1.20-d5de62df15 Thu Nov 24 06:48:07 2022 +0000
uname -v: Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103
ProductName:		macOS
ProductVersion:		13.0.1
BuildVersion:		22A400
lldb --version: lldb-1400.0.38.13
Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)

What did you do?

Rebuild from the source (run all.bash)

What did you expect to see?

No error

What did you see instead?

ok  	os	1.111s
--- FAIL: TestCredentialNoSetGroups (0.00s)
    exec_posix_test.go:47: error getting current user: user: unknown userid 501
FAIL
FAIL	os/exec	0.555s
ok  	os/exec/internal/fdtest	0.222s
ok  	os/signal	3.320s
--- FAIL: TestCurrent (0.00s)
    user_test.go:21: Current: user: unknown userid 501 (got (*user.User)(nil))
--- FAIL: TestLookup (0.00s)
    user_test.go:60: Current: user: unknown userid 501
--- FAIL: TestLookupId (0.00s)
    user_test.go:77: Current: user: unknown userid 501
--- FAIL: TestLookupGroup (0.00s)
    user_test.go:97: Current(): user: unknown userid 501
--- FAIL: TestGroupIds (0.00s)
    user_test.go:132: Current(): user: unknown userid 501
FAIL
FAIL	os/user	0.290s
ok  	path	0.221s
@seankhliao
Copy link
Member

are you uid 501?
does it also fail without cgo?

@YoshikiShibata
Copy link
Author

Yes, my UserID is 501 which is the first user account after setting up macOS.

@YoshikiShibata
Copy link
Author

Without cgo:

--- FAIL: TestCredentialNoSetGroups (0.00s)
    exec_posix_test.go:47: error getting current user: user: unknown userid 501
FAIL
FAIL	os/exec	0.544s
ok  	os/exec/internal/fdtest	0.214s
ok  	os/signal	2.776s
--- FAIL: TestCurrent (0.00s)
    user_test.go:21: Current: user: unknown userid 501 (got (*user.User)(nil))
--- FAIL: TestLookup (0.00s)
    user_test.go:60: Current: user: unknown userid 501
--- FAIL: TestLookupId (0.00s)
    user_test.go:77: Current: user: unknown userid 501
--- FAIL: TestLookupGroup (0.00s)
    user_test.go:97: Current(): user: unknown userid 501
--- FAIL: TestGroupIds (0.00s)
    user_test.go:132: Current(): user: unknown userid 501
FAIL
FAIL	os/user	0.269s
ok  	path	0.225s

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 26, 2022
@andlabs
Copy link
Contributor

andlabs commented Dec 6, 2022

501 is the standard UID for the first user on macOS. The non-cgo non-syscall path looks at /etc/passwd, which explicitly says is only used in single-user mode and does not contain any actual users (at least as far back as 10.12 and as recent as 12.6.1). No idea what's going on in the syscall path, unless it's also not using that path and going down the non-cgo path instead?

@rsc
Copy link
Contributor

rsc commented Dec 7, 2022

The non-cgo path does not run on macOS anymore. That file says

//go:build ((unix && !android) || (js && wasm)) && ((!cgo && !darwin) || osusergo)

The cgo_lookup_unix.go code, despite the file name, runs always on macOS, since it doesn't actually use cgo (it uses direct libc calls instead):

//go:build (cgo || darwin) && !osusergo && unix && !android

So there shouldn't be any problem with cgo vs non-cgo. And nothing should be reading /etc/passwd.

Clearly something about the cgo path is not right anymore.

@rsc rsc self-assigned this Dec 7, 2022
@rsc
Copy link
Contributor

rsc commented Dec 7, 2022

I can't seem to reproduce this on either of my Macs. It would help if you could check which of these two CLs introduces the breakage:

2022-11-10 c3d444d os/user: allocate buffers in Go memory, not C memory
2022-11-10 185766d os/user: use libc (not cgo) on macOS

My guess is the first one is OK and the second one is what breaks. But knowing for sure would help narrow the search. Thanks.

@rsc rsc added this to the Go1.20 milestone Dec 7, 2022
@gopherbot
Copy link

Change https://go.dev/cl/455815 mentions this issue: os/user: fix buffer retry loop on macOS

@rsc
Copy link
Contributor

rsc commented Dec 7, 2022

Found the problem, CL sent.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Dec 7, 2022
@golang golang locked and limited conversation to collaborators Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

6 participants