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: panic during prove #68816

Closed
ALTree opened this issue Aug 9, 2024 · 4 comments
Closed

cmd/compile: internal compiler error: panic during prove #68816

ALTree opened this issue Aug 9, 2024 · 4 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@ALTree
Copy link
Member

ALTree commented Aug 9, 2024

$ gotip version
go version devel go1.24-760b722c Fri Aug 9 14:54:31 2024 +0000 linux/amd64
package p

var v []func()

func f(i int) {
	v = make([]func(), -2|i)
}
$ gotip build crash.go
# command-line-arguments
./crash.go:7:1: internal compiler error: 'f': panic during prove while compiling f:

runtime error: invalid memory address or nil pointer dereference

goroutine 9 [running]:
cmd/compile/internal/ssa.Compile.func1()
	./desktop/gotip/src/cmd/compile/internal/ssa/compile.go:49 +0x6c
panic({0xdacd40?, 0x14e8b40?})
	./desktop/gotip/src/runtime/panic.go:785 +0x132
cmd/compile/internal/ssa.removeBranch(0x0, 0x0)
	./desktop/gotip/src/cmd/compile/internal/ssa/prove.go:2160 +0x22

...
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 9, 2024
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 9, 2024
@ALTree
Copy link
Member Author

ALTree commented Aug 9, 2024

cc @randall77

@randall77
Copy link
Contributor

The reason it is panicking is because prove thinks the first block of the function is unreachable. I think there is some confusion lurking here between "unreachable" and "unconditionally panics" (the first block of f is the latter, but it isn't the former).

This is maybe a better example:

package p

var v []func()

func f(i, j int) {
	if j > 0 {
		v = make([]func(), -2|i)
	}
}

This function currently compiles to just RET. It should compile to something that will panic if j>0.

@randall77 randall77 self-assigned this Aug 9, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/604118 mentions this issue: cmd/compile: in prove pass, check for unsat before adding local facts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants