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: type2 reports wrong internal compiler error with -d=panic #44445

Open
cuonglm opened this issue Feb 20, 2021 · 3 comments
Open

cmd/compile: type2 reports wrong internal compiler error with -d=panic #44445

cuonglm opened this issue Feb 20, 2021 · 3 comments
Milestone

Comments

@cuonglm
Copy link
Contributor

@cuonglm cuonglm commented Feb 20, 2021

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

tip

Does this issue reproduce with the latest release?

No

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

go env Output
$ go env

What did you do?

Compile this program with go tool compile -d=panic -G=1 main.go

package main

import "sort"

func main() {
	sort.Sort(nil);
	var x int;
	sort(x);	// ERROR "package"
}

What did you expect to see?

main.go:8:2: use of package sort not in selector

What did you see instead?

main.go:8:2: use of package sort not in selector
<unknown line number>: internal compiler error: conf.Check error: main.go:8:2: use of package sort not in selector

goroutine 1 [running]:
runtime/debug.Stack(0x104ce18b8, 0x14000130008, 0x0)
	/Users/cuonglm/sources/go/src/runtime/debug/stack.go:24 +0x88
cmd/compile/internal/base.FatalfAt(0x0, 0x104ab6ab2, 0x14, 0x14000145880, 0x1, 0x1)
	/Users/cuonglm/sources/go/src/cmd/compile/internal/base/print.go:227 +0x18c
cmd/compile/internal/noder.check2(0x14000130160, 0x1, 0x1)
	/Users/cuonglm/sources/go/src/cmd/compile/internal/noder/irgen.go:72 +0x394
cmd/compile/internal/noder.LoadPackage(0x14000134070, 0x1, 0x1)
	/Users/cuonglm/sources/go/src/cmd/compile/internal/noder/noder.go:77 +0xc6c
cmd/compile/internal/gc.Main(0x104cd2548)
	/Users/cuonglm/sources/go/src/cmd/compile/internal/gc/main.go:187 +0x938
main.main()
	/Users/cuonglm/sources/go/src/cmd/compile/main.go:54 +0xb0

The old type checker is also panic, but that's a real bug there which I fixed in https://go-review.googlesource.com/c/go/+/294031/5

@cuonglm
Copy link
Contributor Author

@cuonglm cuonglm commented Feb 20, 2021

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Feb 20, 2021

Probably we should just move the ExitIfErrors here above the if err != nil check:

pkg, err := conf.Check(base.Ctxt.Pkgpath, files, &info)
files = nil
if err != nil {
base.FatalfAt(src.NoXPos, "conf.Check error: %v", err)
}
base.ExitIfErrors()

That would ensure we exit gracefully if we've reported any errors, and still ICE if for some unusual reason typechecking failed but we didn't report any errors.

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 21, 2021

Change https://golang.org/cl/294850 mentions this issue: cmd/compile: make check2 gracefully exit if it reported errors

@cagedmantis cagedmantis added this to the Backlog milestone Feb 23, 2021
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