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

Closed
josharian opened this issue May 5, 2017 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@josharian
Copy link
Contributor

package p

import "unsafe"

const (
	a = unsafe.Sizeof(func() int {
		return 0
	}())
	b
)
$ 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
cmd/compile/internal/gc.Main(0x17b2080)
	/Users/josh/go/tip/src/cmd/compile/internal/gc/main.go:545 +0x2392
main.main()
	/Users/josh/go/tip/src/cmd/compile/main.go:49 +0x95

Found with go-fuzz. Low priority.

@josharian
Copy link
Contributor Author

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 The path to resolution is known, but the work has not been done. label Sep 22, 2018
@ALTree
Copy link
Member

ALTree 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 as completed Jul 1, 2019
@golang golang locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants