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: width not calculated: interface {}" when building tiny program with -c=2 #20174

Closed
ALTree opened this issue Apr 29, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@ALTree
Copy link
Member

commented Apr 29, 2017

$ gotip version
go version devel +cf1b323fc8 Sat Apr 29 15:56:48 2017 +0000 linux/amd64

The following program:

package p

func F() {
	_ = (*interface{})(nil)
	select {
	case _ = <-make(chan interface {
		M()
	}, 1):
	}

}

deterministically crashes the tip compiler when building with -gcflags -c=2 with the following error:

# command-line-arguments
<autogenerated>:1:0: internal compiler error: width not calculated: interface {}

goroutine 20 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
	/home/alberto/go/src/runtime/debug/stack.go:24 +0x79
bootstrap/cmd/compile/internal/gc.Fatalf(0x96b862, 0x18, 0xc42003cc40, 0x1, 0x1)
	/home/alberto/go/src/cmd/compile/internal/gc/subr.go:181 +0x24c
bootstrap/cmd/compile/internal/gc.dowidth(0xc4202ee3c0)
	/home/alberto/go/src/cmd/compile/internal/gc/align.go:192 +0xf86
bootstrap/cmd/compile/internal/types.(*Type).Fields(0xc4202ee3c0, 0xb81c40)
	/home/alberto/go/src/cmd/compile/internal/types/type.go:792 +0x84
bootstrap/cmd/compile/internal/types.(*Type).FieldSlice(0xc4202ee3c0, 0x0, 0x0, 0x0)
	/home/alberto/go/src/cmd/compile/internal/types/type.go:807 +0x2b
bootstrap/cmd/compile/internal/types.(*Type).cmp(0xc4202ee3c0, 0xc420336060, 0x59a300)
	/home/alberto/go/src/cmd/compile/internal/types/type.go:1040 +0xae1
bootstrap/cmd/compile/internal/types.(*Type).cmp(0xc420336000, 0xc420337200, 0xc4200da1c0)
	/home/alberto/go/src/cmd/compile/internal/types/type.go:1093 +0x4ce
bootstrap/cmd/compile/internal/types.(*Type).Compare(0xc420336000, 0xb81c40, 0xc420337200, 0xc4200863a8)
	/home/alberto/go/src/cmd/compile/internal/types/type.go:889 +0x69
bootstrap/cmd/compile/internal/ssa.(*Func).constVal(0xc4200c12c0, 0x80b00000002, 0x61c, 0xb81c40, 0xc420337200, 0xc759e285, 0xc42003d100, 0x8112ff)
	/home/alberto/go/src/cmd/compile/internal/ssa/func.go:413 +0x33b
bootstrap/cmd/compile/internal/ssa.(*Func).ConstNil(0xc4200c12c0, 0x80b00000002, 0xb81c40, 0xc420337200, 0x1)
	/home/alberto/go/src/cmd/compile/internal/ssa/func.go:475 +0x66
bootstrap/cmd/compile/internal/gc.(*state).constNil(0xc4200da1c0, 0xb81c40, 0xc420337200, 0xc4203371a0)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:472 +0x61
bootstrap/cmd/compile/internal/gc.(*state).expr(0xc4200da1c0, 0xc420330a00, 0x0)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:1454 +0x9d9
bootstrap/cmd/compile/internal/gc.(*state).stmt(0xc4200da1c0, 0xc420330b00)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:707 +0x1d2
bootstrap/cmd/compile/internal/gc.(*state).stmtList(0xc4200da1c0, 0xc420310b00)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:511 +0x65
bootstrap/cmd/compile/internal/gc.(*state).call(0xc4200da1c0, 0xc420330880, 0xc4200da100, 0xc4203d35b8)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:3105 +0xfc
bootstrap/cmd/compile/internal/gc.(*state).stmt(0xc4200da1c0, 0xc420330880)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:544 +0x983
bootstrap/cmd/compile/internal/gc.(*state).stmtList(0xc4200da1c0, 0xc420310a80)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:511 +0x65
bootstrap/cmd/compile/internal/gc.(*state).stmt(0xc4200da1c0, 0xc42030d780)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:900 +0x1d21
bootstrap/cmd/compile/internal/gc.(*state).stmtList(0xc4200da1c0, 0xc420310960)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:511 +0x65
bootstrap/cmd/compile/internal/gc.buildssa(0xc4200c1180, 0x1, 0x0)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:197 +0x8c3
bootstrap/cmd/compile/internal/gc.compileSSA(0xc4200c1180, 0x1)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:237 +0x39
bootstrap/cmd/compile/internal/gc.compileFunctions.func2(0xc4203373e0, 0xc42006d7b0, 0x1)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:280 +0x74
created by bootstrap/cmd/compile/internal/gc.compileFunctions
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:283 +0x115

@ALTree ALTree added this to the Go1.9 milestone Apr 29, 2017

@ALTree

This comment has been minimized.

Copy link
Member Author

commented Apr 29, 2017

@josharian

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2017

Thanks, @ALTree. This is a thorny one. The expression (*interface{})(nil) is getting typechecked early on, at a point at which the inner type interface{} is still not resolved, i.e. nil. Then the outer type *interface{} is getting marked as having its width calculated, which means that later, in walk, when we ask to dowidth *interface{}, it returns immediately...so in SSA world, when we need the type interface{}, it has managed to evade being dowidth'd. Still pondering what the right fix is.

@josharian

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2017

Well, I'd like a deep fix, but I don't see one. For now, sprinkle some more checkwidth fairy dust in the typechecker so we can get to the next bug. :/

@gopherbot

This comment has been minimized.

Copy link

commented Apr 30, 2017

CL https://golang.org/cl/42175 mentions this issue.

@gopherbot gopherbot closed this in dfeecda Apr 30, 2017

josharian added a commit to josharian/go that referenced this issue May 2, 2017

cmd/compile: checkwidth T when constructing *T
Without this, T can sneak through to the backend
with its width unknown.

Fixes golang#20174

Change-Id: I9b21e0e2641f75e360cc5e45dcb4eefe8255b675

@golang golang locked and limited conversation to collaborators Apr 30, 2018

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