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: unused auto: .autotmp_4 #62515

Closed
ALTree opened this issue Sep 7, 2023 · 4 comments
Closed

cmd/compile: internal compiler error: unused auto: .autotmp_4 #62515

ALTree opened this issue Sep 7, 2023 · 4 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ALTree
Copy link
Member

ALTree commented Sep 7, 2023

$ gotip version
go version devel go1.22-d9a4b24a Thu Sep 7 15:25:07 2023 +0000 linux/amd64
package main

import "unsafe"

func F[G int](g G) uintptr {
	var c chan func() int
	type s struct {
		_ G
		_ []int
	}
	return unsafe.Sizeof(s{g, make([]int, (<-c)())})
}

func main() {
	F(0)
}
$ gotip build crash.go 

# command-line-arguments
./crash.go:11:45: internal compiler error: unused auto: .autotmp_4

goroutine 1 [running]:
runtime/debug.Stack()
	./desktop/gotip/src/runtime/debug/stack.go:24 +0x5e
cmd/compile/internal/base.FatalfAt({0xcfa3e0?, 0x0?}, {0xd6fb2e, 0xf}, {0xc000409468, 0x1, 0x1})
	./desktop/gotip/src/cmd/compile/internal/base/print.go:225 +0x1d7
cmd/compile/internal/inline.pruneUnusedAutos({0xc00040c6c0, 0x5, 0x1?}, 0xc00040cbc0)
	./desktop/gotip/src/cmd/compile/internal/inline/inl.go:1176 +0x185
cmd/compile/internal/inline.CanInline(0xc000412000, 0x0)
...

Doesn't crash on 1.21

cc @golang/compiler

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 7, 2023
@ALTree ALTree added this to the Go1.22 milestone Sep 7, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Sep 7, 2023
@mauri870
Copy link
Member

mauri870 commented Sep 7, 2023

I was able to bisect the changes and CL 523315 seems to be the culprint.

@mauri870
Copy link
Member

mauri870 commented Sep 7, 2023

cc @mdempsky

@mdempsky mdempsky self-assigned this Sep 8, 2023
@mdempsky mdempsky added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 8, 2023
@cuonglm
Copy link
Member

cuonglm commented Sep 8, 2023

This seems becasue make([]int, (<-c)()) is rewritten into:

var autotmp_4 func() int
autotmp_4 = <-c
return unsafe.Sizeof(s{g, make([]int, autotmp_4())})

Then when reading function body, unified IR eval the unsafe.Sizeof to just return 32, so autotmp_4 appears in F declaration list but is not recorded as used.

@gopherbot
Copy link

Change https://go.dev/cl/527097 mentions this issue: cmd/compile/internal/noder: handle unsafe.Sizeof, etc in unified IR

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. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants