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: the "go tool compile -S -live=2 *.go" command failed #39251

Closed
zhangfannie opened this issue May 26, 2020 · 9 comments
Closed

cmd/compile: the "go tool compile -S -live=2 *.go" command failed #39251

zhangfannie opened this issue May 26, 2020 · 9 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 release-blocker
Milestone

Comments

@zhangfannie
Copy link
Contributor

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

$ go version
go version devel +bcda68447b Mon May 25 21:01:14 2020 +0000 linux/arm64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/fanzha02/.cache/go-build"
GOENV="/home/fanzha02/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/fanzha02/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/fanzha02/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/fanzha02/work/go_project/gomain"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/fanzha02/work/go_project/gomain/pkg/tool/linux_arm64"
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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build178004910=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. cat hello.go
package main
import "fmt"
func main() {
        fmt.Println("hello")
}
  1. go tool compiler -S -live=2 hello.go

What did you expect to see?

pass

What did you see instead?

the command reports the error.

@zhangfannie
Copy link
Contributor Author

The command reports the following error and stack trace.

live=panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
cmd/compile/internal/gc.(*Liveness).printDebug(0x4000279600)
        /home/fanzha02/work/go_project/gomain/src/cmd/compile/internal/gc/plive.go:1450 +0xfec
cmd/compile/internal/gc.liveness(0x40002074a0, 0x4000278840, 0x4000478080, 0x0)
        /home/fanzha02/work/go_project/gomain/src/cmd/compile/internal/gc/plive.go:1593 +0x4ac
cmd/compile/internal/gc.genssa(0x4000278840, 0x4000478080)
        /home/fanzha02/work/go_project/gomain/src/cmd/compile/internal/gc/ssa.go:5939 +0x70
cmd/compile/internal/gc.compileSSA(0x40002782c0, 0x0)
        /home/fanzha02/work/go_project/gomain/src/cmd/compile/internal/gc/pgen.go:327 +0x3a0
cmd/compile/internal/gc.compile(0x40002782c0)
        /home/fanzha02/work/go_project/gomain/src/cmd/compile/internal/gc/pgen.go:275 +0x350
cmd/compile/internal/gc.funccompile(0x40002782c0)
        /home/fanzha02/work/go_project/gomain/src/cmd/compile/internal/gc/pgen.go:220 +0xc8
cmd/compile/internal/gc.Main(0x796a00)
        /home/fanzha02/work/go_project/gomain/src/cmd/compile/internal/gc/main.go:747 +0x36cc
main.main()
        /home/fanzha02/work/go_project/gomain/src/cmd/compile/main.go:52 +0xb8

@zhangfannie
Copy link
Contributor Author

The line 1450 of plive.go, the code is regLive := lv.regMaps[pcdata.regMapIndex], because the len(lv.regMaps) is equal to 0, which leads to an error.
But I found a comment "Only when! Go115ReduceLiveness" next to this line of code, I don't know if there are any other conditions for using "-live = 2". Thank you.

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 26, 2020
@ALTree ALTree changed the title cmd/compier: the "go tool compie -S -live=2 *.go" command failed. cmd/compile: the "go tool compie -S -live=2 *.go" command failed May 26, 2020
@ALTree ALTree added this to the Go1.16 milestone May 26, 2020
@ALTree
Copy link
Member

ALTree commented May 26, 2020

This is a tip regression: Go1.14.2 does not crash.

@ALTree ALTree modified the milestones: Go1.16, Go1.15 May 26, 2020
@ALTree ALTree changed the title cmd/compile: the "go tool compie -S -live=2 *.go" command failed cmd/compile: the "go tool compile -S -live=2 *.go" command failed May 26, 2020
@mariecurried
Copy link

Took a shot at bisecting this. Commit 9d812cf seems to be the culprit.

@ALTree
Copy link
Member

ALTree commented May 26, 2020

cc @aclements @cherrymui

@ianlancetaylor
Copy link
Contributor

CC @dr2chase

@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented May 26, 2020

Marking as release blocker since it is a regression that causes a compiler crash.

@ianlancetaylor ianlancetaylor added the okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 label May 26, 2020
@ianlancetaylor
Copy link
Contributor

Marking okay-after-beta1 since it is an unusual set of options.

@gopherbot
Copy link

Change https://golang.org/cl/235418 mentions this issue: cmd/compile: when register map is not used, treat it as invalid

@golang golang locked and limited conversation to collaborators May 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants