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

cmd/compile: internal compiler error: conflicting package heights 4 and 3 for path "sync" #44337

Closed
xaionaro opened this issue Feb 17, 2021 · 8 comments

Comments

@xaionaro
Copy link
Contributor

@xaionaro xaionaro commented Feb 17, 2021

If I run a command without option -race

go/pkg/tool/linux_amd64/compile -p main -pack -trimpath /data/users/xaionaro/fbsource/fbcode -nolocalimports -buildid= -o buck-out/dev/gen/privatecore/firmware/analyzer/cmd/firmware-analyzer/firmware-analyzer.race#compile,platform007-clang/firmware-analyzer.race.a -I /data/users/xaionaro/fbsource/fbcode/buck-out/dev/bin/privatecore/firmware/analyzer/cmd/firmware-analyzer/__firmware-analyzer.race#compile,platform007-clang,symlink-tree__tree -complete /data/users/xaionaro/fbsource/fbcode/buck-out/dev/gen/privatecore/firmware/analyzer/cmd/firmware-analyzer/firmware-analyzer.race-go-build-info/firmware-analyzer.race-go-build-info.go /data/users/xaionaro/fbsource/fbcode/privatecore/firmware/analyzer/cmd/firmware-analyzer/main.go

it works.

If I add option -race it fails:

go/pkg/tool/linux_amd64/compile -p main -pack -trimpath /data/users/xaionaro/fbsource/fbcode -nolocalimports -race -buildid= -o buck-out/dev/gen/privatecore/firmware/analyzer/cmd/firmware-analyzer/firmware-analyzer.race#compile,platform007-clang/firmware-analyzer.race.a -I /data/users/xaionaro/fbsource/fbcode/buck-out/dev/bin/privatecore/firmware/analyzer/cmd/firmware-analyzer/__firmware-analyzer.race#compile,platform007-clang,symlink-tree__tree -complete /data/users/xaionaro/fbsource/fbcode/buck-out/dev/gen/privatecore/firmware/analyzer/cmd/firmware-analyzer/firmware-analyzer.race-go-build-info/firmware-analyzer.race-go-build-info.go /data/users/xaionaro/fbsource/fbcode/privatecore/firmware/analyzer/cmd/firmware-analyzer/main.go
/data/users/xaionaro/fbsource/fbcode/privatecore/firmware/analyzer/cmd/firmware-analyzer/main.go:11:2: internal compiler error: conflicting package heights 4 and 3 for path "sync"

Please file a bug report including a short program that triggers the error.
https://golang.org/issue/new

Unfortunately I cannot share main.go, since it is under NDA. And if I try to minimize main.go (remove all NDA-code) then it stops failing.

$ go version
go version go1.15.2 linux/amd64
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/xaionaro/.local/bin"
GOCACHE="/home/xaionaro/.cache/go-build"
GOENV="/home/xaionaro/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/data/users/xaionaro/gopaths/gobuck/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/data/users/xaionaro/gopaths/gobuck:/data/users/xaionaro/gopaths/godeps:/home/xaionaro/fbcode-gen-go:/data/users/xaionaro/gopaths/gofbcode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/data/users/xaionaro/gopaths/goroot"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/data/users/xaionaro/gopaths/goroot/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build350343079=/tmp/go-build -gno-record-gcc-switches"
@xaionaro xaionaro changed the title internal compiler error: conflicting package heights 4 and 3 for path "sync" cmd/compile: internal compiler error: conflicting package heights 4 and 3 for path "sync" Feb 17, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 17, 2021

Loading

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 17, 2021

Does this happen when using go build? Or does it only happen when invoking cmd/compile directly? If the latter, why are you doing that?

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 17, 2021

cc @mdempsky (who implemented the package height mechanism)

Loading

@xaionaro
Copy link
Contributor Author

@xaionaro xaionaro commented Feb 17, 2021

Does this happen when using go build? Or does it only happen when invoking cmd/compile directly?

Command:

go/bin/go build -race -o 'buck-out/dev/gen/privatecore/firmware/analyzer/cmd/firmware-analyzer/firmware-analyzer.race#compile,platform007-clang/firmware-analyzer.race.a' -gcflags '-I /data/users/xaionaro/fbsource/fbcode/third-party-buck/platform007/tools/go/src/ -p main -pack -trimpath /data/users/xaionaro/fbsource/fbcode -nolocalimports -buildid= -I /data/users/xaionaro/fbsource/fbcode/buck-out/dev/bin/privatecore/firmware/analyzer/cmd/firmware-analyzer/__firmware-analyzer.race#compile,platform007-clang,symlink-tree__tree -complete' /data/users/xaionaro/fbsource/fbcode/privatecore/firmware/analyzer/cmd/firmware-analyzer/main.go

works.

[xaionaro@devvm018.cln0 ~/fbcode] ls -ld 'buck-out/dev/gen/privatecore/firmware/analyzer/cmd/firmware-analyzer/firmware-analyzer.race#compile,platform007-clang/firmware-analyzer.race.a'
-rwxr-xr-x 1 xaionaro users 56831949 Feb 17 12:24 buck-out/dev/gen/privatecore/firmware/analyzer/cmd/firmware-analyzer/firmware-analyzer.race#compile,platform007-clang/firmware-analyzer.race.a

If the latter, why are you doing that?

This command was automatically generated by our building system, when I tried to add -race flag to catch a race condition in the code. And if the command is wrong, then it would be nice to print a proper description of what exactly is wrong, IMVHO :)


P.S.:

I've just tried to move -race into -gcflags:

go/bin/go build -o 'buck-out/dev/gen/privatecore/firmware/analyzer/cmd/firmware-analyzer/firmware-analyzer.race#compile,platform007-clang/firmware-analyzer.race.a' -gcflags '-I /data/users/xaionaro/fbsource/fbcode/third-party-buck/platform007/tools/go/src/ -p main -pack -trimpath /data/users/xaionaro/fbsource/fbcode -nolocalimports -buildid= -I /data/users/xaionaro/fbsource/fbcode/buck-out/dev/bin/privatecore/firmware/analyzer/cmd/firmware-analyzer/__firmware-analyzer.race#compile,platform007-clang,symlink-tree__tree -complete -race' /data/users/xaionaro/fbsource/fbcode/privatecore/firmware/analyzer/cmd/firmware-analyzer/main.go
# command-line-arguments
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x51da5b]

goroutine 1 [running]:
cmd/link/internal/loader.(*Loader).FuncInfo(0xc00006bc00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/engshare/third-party2/go/1.15.2_fb/centos7-native/da39a3e/src/cmd/link/internal/loader/loader.go:1900 +0x9b
cmd/link/internal/ld.(*stkChk).check(0xc0041d4e78, 0xc0041d4d08, 0x1, 0x0)
        /home/engshare/third-party2/go/1.15.2_fb/centos7-native/da39a3e/src/cmd/link/internal/ld/lib.go:2359 +0x130
cmd/link/internal/ld.(*stkChk).check(0xc0041d4e78, 0xc0041d4e60, 0x0, 0x0)
        /home/engshare/third-party2/go/1.15.2_fb/centos7-native/da39a3e/src/cmd/link/internal/ld/lib.go:2418 +0x585
cmd/link/internal/ld.(*Link).dostkcheck(0xc00006b880)
        /home/engshare/third-party2/go/1.15.2_fb/centos7-native/da39a3e/src/cmd/link/internal/ld/lib.go:2319 +0x2bc
cmd/link/internal/ld.Main(0x875840, 0x20, 0x20, 0x1, 0x7, 0x10, 0x0, 0x0, 0x6da8ff, 0x1b, ...)
        /home/engshare/third-party2/go/1.15.2_fb/centos7-native/da39a3e/src/cmd/link/internal/ld/main.go:254 +0xe65
main.main()
        /home/engshare/third-party2/go/1.15.2_fb/centos7-native/da39a3e/src/cmd/link/main.go:68 +0x1dc

Loading

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Feb 17, 2021

You need to either compile all packages with -race or none of them. Mixing packages with different compilation modes like this isn't supported.

The recommended way to use the race detector is to use go build -race or go install -race. If you're going to try to use -gcflags=-race, then you need to at least use -gcflags=all=-race, but I think there may also be linker flags that need to be passed too.

Loading

@xaionaro
Copy link
Contributor Author

@xaionaro xaionaro commented Feb 17, 2021

You need to either compile all packages with -race or none of them. Mixing packages with different compilation modes like this isn't supported.

The recommended way to use the race detector is to use go build -race or go install -race. If you're going to try to use -gcflags=-race, then you need to at least use -gcflags=all=-race, but I think there may also be linker flags that need to be passed too.

OK, this makes sense. Thank you for the clarification!

Loading

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Feb 17, 2021

No problem. I'm going to close the issue because I think this is working as intended.

Loading

@mdempsky mdempsky closed this Feb 17, 2021
@xaionaro
Copy link
Contributor Author

@xaionaro xaionaro commented Feb 17, 2021

No problem. I'm going to close the issue because I think this is working as intended.

The only nitpicking here is: the error message is obscure. Though next users might find this discussion to get a proper answer here :)

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants