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: Crash when looking up user on macOS with -race #49250

Closed
groob opened this issue Oct 31, 2021 · 2 comments
Closed

os/user: Crash when looking up user on macOS with -race #49250

groob opened this issue Oct 31, 2021 · 2 comments

Comments

@groob
Copy link
Contributor

groob commented Oct 31, 2021

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

$ go version
go version go1.17.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes. Tried on Apple Silicon too and the issue is reproducible. Only when building with -race

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/groob/Library/Caches/go-build"
GOENV="/Users/groob/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/groob/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/groob/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/groob/code/os2/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sj/x7mj2d5x7wj4pdgrw9dw8tc00000gn/T/go-build3703116856=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Wrote a simple program calling user.Current() and built it with -race

package main

import "os/user"

func main() {
	user.Current()
}

go build -race -o getuser

What did you expect to see?

Successful execution

What did you see instead?

❯ ./getuser
objc[17910]: Attempt to use unknown class 0x7ff860b23360.
SIGABRT: abort
PC=0x7ff81f2efdfe m=0 sigcode=0

goroutine 0 [idle]:
runtime: unknown pc 0x7ff81f2efdfe
stack: frame={sp:0x7ff7bfefe798, fp:0x0} stack=[0x7ff7bfe80838,0x7ff7bfeff8a0)
0x00007ff7bfefe698:  0x0000000000000002  0x0000000000000002
0x00007ff7bfefe6a8:  0x0000000001c7d000  0x0000000001c7d400
0x00007ff7bfefe6b8:  0x0000000000000008  0x00007ff7bfefe720
0x00007ff7bfefe6c8:  0x00007ff81f125639  0x0000000000000000
0x00007ff7bfefe6d8:  0xf6ae8000c0001008  0x000000000000ffff
0x00007ff7bfefe6e8:  0x0000000000000030  0x0000000000000000
0x00007ff7bfefe6f8:  0x000000000000002d  0x000000000000002d
0x00007ff7bfefe708:  0x0000000000000000  0x0000000001c7d000
0x00007ff7bfefe718:  0x00007ff860b37000  0x00007ff7bfefe750
0x00007ff7bfefe728:  0x00007ff81f125566  0x00007ff81f12552e
0x00007ff7bfefe738:  0x000000000000002d  0x0000000000000001
0x00007ff7bfefe748:  0x00007ff860b37000  0x00007ff7bfefe790
0x00007ff7bfefe758:  0x00007ff81f141ad6  0x000000000000002c
0x00007ff7bfefe768:  0x000000000000002d  0x0000600003300000
0x00007ff7bfefe778:  0x0000000000000003  0x0000600002c00000
0x00007ff7bfefe788:  0x0000000000000000  0x00007ff7bfefe7c0
0x00007ff7bfefe798: <0x00007ff81f2f1893  0x0000000000000000
0x00007ff7bfefe7a8:  0x00000020bfefe800  0x0000600002c00000
0x00007ff7bfefe7b8:  0x00007ff7bfefe800  0x0000600003300000
0x00007ff7bfefe7c8:  0x0000000000000003  0x0000000000000080
0x00007ff7bfefe7d8:  0x0000000000000001  0x00007ff7bfefe7f0
0x00007ff7bfefe7e8:  0x00007ff81f2f1843  0x00007ff7bfefe830
0x00007ff7bfefe7f8:  0x00007ff81f1bdbce  0x0000600002c00080
0x00007ff7bfefe808:  0x0000000000000000  0x0000600002c00000
0x00007ff7bfefe818:  0x00007ffffffffff8  0x00007ff860b23360
0x00007ff7bfefe828:  0x0000000080080001  0x00007ff7bfefe910
0x00007ff7bfefe838:  0x00007ff81f1bdb5c  0x0000003000000010
0x00007ff7bfefe848:  0x00007ff7bfefe920  0x00007ff7bfefe860
0x00007ff7bfefe858:  0x00007ff7bfefe990  0x00000000077a63a0
0x00007ff7bfefe868:  0x00007ff860b23360  0x00007ff860b23360
0x00007ff7bfefe878:  0x0000000000000001  0x00000000ffffffff
0x00007ff7bfefe888:  0x0000000000000000  0x00007ff7bfefe8b0
runtime: unknown pc 0x7ff81f2efdfe
stack: frame={sp:0x7ff7bfefe798, fp:0x0} stack=[0x7ff7bfe80838,0x7ff7bfeff8a0)
0x00007ff7bfefe698:  0x0000000000000002  0x0000000000000002
0x00007ff7bfefe6a8:  0x0000000001c7d000  0x0000000001c7d400
0x00007ff7bfefe6b8:  0x0000000000000008  0x00007ff7bfefe720
0x00007ff7bfefe6c8:  0x00007ff81f125639  0x0000000000000000
0x00007ff7bfefe6d8:  0xf6ae8000c0001008  0x000000000000ffff
0x00007ff7bfefe6e8:  0x0000000000000030  0x0000000000000000
0x00007ff7bfefe6f8:  0x000000000000002d  0x000000000000002d
0x00007ff7bfefe708:  0x0000000000000000  0x0000000001c7d000
0x00007ff7bfefe718:  0x00007ff860b37000  0x00007ff7bfefe750
0x00007ff7bfefe728:  0x00007ff81f125566  0x00007ff81f12552e
0x00007ff7bfefe738:  0x000000000000002d  0x0000000000000001
0x00007ff7bfefe748:  0x00007ff860b37000  0x00007ff7bfefe790
0x00007ff7bfefe758:  0x00007ff81f141ad6  0x000000000000002c
0x00007ff7bfefe768:  0x000000000000002d  0x0000600003300000
0x00007ff7bfefe778:  0x0000000000000003  0x0000600002c00000
0x00007ff7bfefe788:  0x0000000000000000  0x00007ff7bfefe7c0
0x00007ff7bfefe798: <0x00007ff81f2f1893  0x0000000000000000
0x00007ff7bfefe7a8:  0x00000020bfefe800  0x0000600002c00000
0x00007ff7bfefe7b8:  0x00007ff7bfefe800  0x0000600003300000
0x00007ff7bfefe7c8:  0x0000000000000003  0x0000000000000080
0x00007ff7bfefe7d8:  0x0000000000000001  0x00007ff7bfefe7f0
0x00007ff7bfefe7e8:  0x00007ff81f2f1843  0x00007ff7bfefe830
0x00007ff7bfefe7f8:  0x00007ff81f1bdbce  0x0000600002c00080
0x00007ff7bfefe808:  0x0000000000000000  0x0000600002c00000
0x00007ff7bfefe818:  0x00007ffffffffff8  0x00007ff860b23360
0x00007ff7bfefe828:  0x0000000080080001  0x00007ff7bfefe910
0x00007ff7bfefe838:  0x00007ff81f1bdb5c  0x0000003000000010
0x00007ff7bfefe848:  0x00007ff7bfefe920  0x00007ff7bfefe860
0x00007ff7bfefe858:  0x00007ff7bfefe990  0x00000000077a63a0
0x00007ff7bfefe868:  0x00007ff860b23360  0x00007ff860b23360
0x00007ff7bfefe878:  0x0000000000000001  0x00000000ffffffff
0x00007ff7bfefe888:  0x0000000000000000  0x00007ff7bfefe8b0

goroutine 1 [syscall]:
runtime.cgocall(0x10011c0, 0xc000125b60)
	/usr/local/go/src/runtime/cgocall.go:156 +0x6e fp=0xc000125b38 sp=0xc000125b00 pc=0x1043c6e
os/user._Cfunc_mygetpwuid_r(0x1f5, 0xc00010e050, 0x2a008200, 0x1000, 0xc000138018)
	_cgo_gotypes.go:181 +0x85 fp=0xc000125b60 sp=0xc000125b38 pc=0x10ed1c5
os/user.lookupUnixUid.func1.1(0x1f5, 0x1c99a68, 0xc00011a210, 0x11d6260)
	/usr/local/go/src/os/user/cgo_lookup_unix.go:105 +0xdc fp=0xc000125bc8 sp=0xc000125b60 pc=0x10edc1c
os/user.lookupUnixUid.func1()
	/usr/local/go/src/os/user/cgo_lookup_unix.go:105 +0x5e fp=0xc000125c20 sp=0xc000125bc8 pc=0x10edb1e
os/user.retryWithBuffer(0xc00011a210, 0xc000125d78)
	/usr/local/go/src/os/user/cgo_lookup_unix.go:249 +0x42 fp=0xc000125c80 sp=0xc000125c20 pc=0x10ee4a2
os/user.lookupUnixUid(0x1f5)
	/usr/local/go/src/os/user/cgo_lookup_unix.go:98 +0x1de fp=0xc000125db0 sp=0xc000125c80 pc=0x10ed83e
os/user.current()
	/usr/local/go/src/os/user/cgo_lookup_unix.go:51 +0x2a fp=0xc000125de0 sp=0xc000125db0 pc=0x10ed62a
os/user.Current.func1()
	/usr/local/go/src/os/user/lookup.go:15 +0x2a fp=0xc000125e10 sp=0xc000125de0 pc=0x10ee5ca
sync.(*Once).doSlow(0x11d5e60, 0x11142c0)
	/usr/local/go/src/sync/once.go:68 +0x128 fp=0xc000125ef8 sp=0xc000125e10 pc=0x10a4568
sync.(*Once).Do(0x11d5e60, 0x1074539)
	/usr/local/go/src/sync/once.go:59 +0x47 fp=0xc000125f20 sp=0xc000125ef8 pc=0x10a4407
os/user.Current()
	/usr/local/go/src/os/user/lookup.go:15 +0x38 fp=0xc000125f68 sp=0xc000125f20 pc=0x10ece98
main.main()
	/Users/groob/code/os2/main.go:6 +0x25 fp=0xc000125f80 sp=0xc000125f68 pc=0x10eeba5
runtime.main()
	/usr/local/go/src/runtime/proc.go:255 +0x227 fp=0xc000125fe0 sp=0xc000125f80 pc=0x1074567
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000125fe8 sp=0xc000125fe0 pc=0x109f3a1

rax    0x2000209
rbx    0x80
rcx    0x7ff7bfefe798
rdx    0x0
rdi    0x8
rsi    0x1
rbp    0x7ff7bfefe7e0
rsp    0x7ff7bfefe798
r8     0x600002c00000
r9     0x80
r10    0x0
r11    0x246
r12    0x0
r13    0x0
r14    0x1
r15    0x8
rip    0x7ff81f2efdfe
rflags 0x246
cs     0x7
fs     0x0
gs     0x0
@randall77
Copy link
Contributor

Probably a dup of #49138. Can you try setting MallocNanoZone=0 to see if that fixes it?

@groob
Copy link
Contributor Author

groob commented Oct 31, 2021

Indeed. Setting MallocNanoZone fixes the problem for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants