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: esc return list involving constant groups and unsafe.Sizeof #20260

josharian opened this issue May 5, 2017 · 2 comments


None yet
2 participants
Copy link

commented May 5, 2017

package p

import "unsafe"

const (
	a = unsafe.Sizeof(func() int {
		return 0
$ go tool compile x.go 
x.go:7:3: internal compiler error: esc return list

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
	/Users/josh/go/tip/src/runtime/debug/stack.go:24 +0xa7
cmd/compile/internal/gc.Fatalf(0x179c214, 0xf, 0x0, 0x0, 0x0)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/subr.go:181 +0x230
cmd/compile/internal/gc.(*EscState).esc(0xc4200b8400, 0xc4202f7280, 0xc420316280)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/esc.go:871 +0x127d
cmd/compile/internal/gc.(*EscState).esclist(0xc4200b8400, 0xc4202eff40, 0xc420316280)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/esc.go:648 +0x6d
cmd/compile/internal/gc.(*EscState).escfunc(0xc4200b8400, 0xc420316280)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/esc.go:589 +0x18c
cmd/compile/internal/gc.escAnalyze(0xc42000c5e0, 0x1, 0x1, 0xc42031e000)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/esc.go:491 +0x566
cmd/compile/internal/gc.(*bottomUpVisitor).visit(0xc420333810, 0xc420316280, 0xc400000002)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/esc.go:107 +0x25c
cmd/compile/internal/gc.visitBottomUp(0xc4202efd40, 0x4, 0x4, 0x17b2200)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/esc.go:63 +0xeb
cmd/compile/internal/gc.escapes(0xc4202efd40, 0x4, 0x4)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/esc.go:187 +0x4b
	/Users/josh/go/tip/src/cmd/compile/internal/gc/main.go:545 +0x2392
	/Users/josh/go/tip/src/cmd/compile/main.go:49 +0x95

Found with go-fuzz. Low priority.


This comment has been minimized.

Copy link
Contributor Author

commented May 5, 2017

Per #20262 and #12946, the bug here is that escape analysis is looking inside the function at all. The fix is probably to nil out the body of the function once typechecking has decided that we're working with unsafe.Sizeof and has determined the type of the return value.

@ALTree ALTree added the NeedsFix label Sep 22, 2018


This comment has been minimized.

Copy link

commented Jul 1, 2019

I can't reproduce this on tip (to be 1.13), so it's possible that this was fixed by the recent escape analysis rewrite. Optimistically closing.

@ALTree ALTree closed this Jul 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.