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: not lowered: v403, Store SSA UINTPTR INT SSA #28430

Closed
kenXengineering opened this issue Oct 26, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@kenXengineering
Copy link

commented Oct 26, 2018

What version of Go are you using (go version)?

go version devel +18b84cbd42 Fri Oct 26 20:13:40 2018 +0000 linux/amd64

Running all.bash passed all tests.

Does this issue reproduce with the latest release?

go version go1.11.1 linux/amd64 - No, compile successfully

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/chosenken/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/chosenken/code/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go_latest"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go_latest/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build735969012=/tmp/go-build -gno-record-gcc-switches"

Arch Linux x64, Dell XPS 9560

What did you do?

Attempting to compile dgraph-io/badger at commit 758c4ba9 causes the following internal compile error:

$ go build -v                                                       
github.com/dgraph-io/badger/table
# github.com/dgraph-io/badger/table
../table/builder.go:207:2: internal compiler error: '(*Builder).Finish': not lowered: v403, Store SSA UINTPTR INT SSA

goroutine 9 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
	/usr/lib/go_latest/src/runtime/debug/stack.go:24 +0xa7
cmd/compile/internal/gc.Fatalf(0xc00095c298, 0x8, 0xc000ab8100, 0x2, 0x2)
	/usr/lib/go_latest/src/cmd/compile/internal/gc/subr.go:182 +0x1e7
cmd/compile/internal/gc.(*ssafn).Fatalf(0xc000770180, 0xcf02100000002, 0xcce571, 0x2, 0xc000ab6070, 0x1, 0x1)
	/usr/lib/go_latest/src/cmd/compile/internal/gc/ssa.go:5789 +0x1ba
cmd/compile/internal/ssa.(*Func).Fatalf(0xc00084a000, 0xcce571, 0x2, 0xc000ab6070, 0x1, 0x1)
	/usr/lib/go_latest/src/cmd/compile/internal/ssa/func.go:576 +0x78
cmd/compile/internal/ssa.checkLower(0xc00084a000)
	/usr/lib/go_latest/src/cmd/compile/internal/ssa/lower.go:36 +0x34a
cmd/compile/internal/ssa.Compile(0xc00084a000)
	/usr/lib/go_latest/src/cmd/compile/internal/ssa/compile.go:72 +0x2bb
cmd/compile/internal/gc.buildssa(0xc00042b1e0, 0x0, 0x0)
	/usr/lib/go_latest/src/cmd/compile/internal/gc/ssa.go:231 +0xaa7
cmd/compile/internal/gc.compileSSA(0xc00042b1e0, 0x0)
	/usr/lib/go_latest/src/cmd/compile/internal/gc/pgen.go:278 +0x39
cmd/compile/internal/gc.compileFunctions.func2(0xc0008233e0, 0xc0007cebb0, 0x0)
	/usr/lib/go_latest/src/cmd/compile/internal/gc/pgen.go:342 +0x49
created by cmd/compile/internal/gc.compileFunctions
	/usr/lib/go_latest/src/cmd/compile/internal/gc/pgen.go:340 +0x132

Error happens on the for line in the following function (table/builder.go):

// Finish finishes the table by appending the index.
func (b *Builder) Finish() []byte {
	bf := bbloom.New(float64(b.keyCount), 0.01)
	var klen [2]byte
	key := make([]byte, 1024)
	for {
		if _, err := b.keyBuf.Read(klen[:]); err == io.EOF {
			break
		} else if err != nil {
			y.Check(err)
		}
		kl := int(binary.BigEndian.Uint16(klen[:]))
		if cap(key) < kl {
			key = make([]byte, 2*int(kl)) // 2 * uint16 will overflow
		}
		key = key[:kl]
		y.Check2(b.keyBuf.Read(key))
		bf.Add(key)
	}

	b.finishBlock() // This will never start a new block.
	index := b.blockIndex()
	b.buf.Write(index)

	// Write bloom filter.
	bdata := bf.JSONMarshal()
	n, err := b.buf.Write(bdata)
	y.Check(err)
	var buf [4]byte
	binary.BigEndian.PutUint32(buf[:], uint32(n))
	b.buf.Write(buf[:])

	return b.buf.Bytes()
}
@agnivade

This comment has been minimized.

Copy link
Member

commented Oct 27, 2018

A bisect would be extremely helpful.

@randall77

This comment has been minimized.

Copy link
Contributor

commented Oct 27, 2018

I traced the error back from ssa to the AST after walk. It has this call:

. . CALLFUNC l(218) tc(1) hascall
. . . NAME-y.Check2 a(true) l(48) x(0) class(PFUNC) tc(1) used FUNC-func(interface {}, error)
. . CALLFUNC-rlist
. . . CONVNOP l(218) tc(1) int
. . . . NAME-bytes.n a(true) l(299) x(0) class(PAUTO) tc(1) assigned used int
 
. . . NAME-bytes.err a(true) l(299) x(0) class(PAUTO) tc(1) assigned used error

It's passing the wrong type to the first argument. There needs to be a real CONV, not a CONVNOP, as it has to convert from an int to an interface{}.

Here's a simple repro:

package main

func g(_ interface{}, e error)
func h() (int, error)

func f() {
	g(h())
}
@josharian

This comment has been minimized.

Copy link
Contributor

commented Oct 27, 2018

@randall77

This comment has been minimized.

Copy link
Contributor

commented Oct 27, 2018

@josharian It's your CL https://go-review.googlesource.com/c/114797 that caused it.
... and the CL in #28390 fixes it. I'll close as a dup.
My repro might be good to add there as another test.

@randall77 randall77 closed this Oct 27, 2018

@gopherbot

This comment has been minimized.

Copy link

commented Oct 28, 2018

Change https://golang.org/cl/144598 mentions this issue: cmd/compile: convert arguments as needed

gopherbot pushed a commit that referenced this issue Oct 28, 2018

cmd/compile: convert arguments as needed
CL 114797 reworked how arguments get written to the stack.
Some type conversions got lost in the process. Restore them.

Fixes #28390
Updates #28430

Change-Id: Ia0d37428d7d615c865500bbd1a7a4167554ee34f
Reviewed-on: https://go-review.googlesource.com/c/144598
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
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.