Closed
Description
What version of Go are you using (go version
)?
$ go version go version devel +9a00e64633 Fri Jul 5 12:11:36 2019 +0000 linux/amd6
Does this issue reproduce with the latest release?
No.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/home/jeff/.cache/go-build" GOENV="/home/jeff/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/jeff/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org" GOROOT="/home/jeff/gotip" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/jeff/gotip/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/jeff/tmp/crash/go.mod" 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-build477512344=/tmp/go-build -gno-record-gcc-switches"
What did you do?
package main
import "unsafe"
func main() {
var l uint64
var p unsafe.Pointer
_ = unsafe.Pointer(uintptr(p) + (uintptr(l) >> 1))
}
What did you expect to see?
Successful compilation.
What did you see instead?
# crash
./foo.go:10:20: internal compiler error: unexpected type uint for 1
goroutine 1 [running]:
runtime/debug.Stack(0xfdc4a0, 0xc0000b6008, 0x0)
/home/jeff/gotip/src/runtime/debug/stack.go:24 +0x9d
cmd/compile/internal/gc.Fatalf(0xe45afa, 0x19, 0xc0003491b8, 0x2, 0x2)
/home/jeff/gotip/src/cmd/compile/internal/gc/subr.go:188 +0x291
cmd/compile/internal/gc.(*Escape).unsafeValue(0xc0000f2210, 0xc0000f2278, 0x0, 0xc000360d80)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:597 +0x2a7
cmd/compile/internal/gc.(*Escape).unsafeValue(0xc0000f2210, 0xc0000f2278, 0x0, 0xc000360a80)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:619 +0xc8
cmd/compile/internal/gc.(*Escape).unsafeValue(0xc0000f2210, 0xc0000f2278, 0x0, 0xc000360b80)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:619 +0xc8
cmd/compile/internal/gc.(*Escape).exprSkipInit(0xc0000f2210, 0xc0000f2278, 0x0, 0xc000360780)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:480 +0x723
cmd/compile/internal/gc.(*Escape).expr(0xc0000f2210, 0xc0000f2278, 0x0, 0xc000360780)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:414 +0x6a
cmd/compile/internal/gc.(*Escape).assign(0xc0000f2210, 0xc00033d0e0, 0xc000360780, 0xe35d70, 0x6, 0xc000360700)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:702 +0x17b
cmd/compile/internal/gc.(*Escape).stmt(0xc0000f2210, 0xc000360700)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:364 +0x27c
cmd/compile/internal/gc.(*Escape).stmts(0xc0000f2210, 0xc00037c7a0)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:403 +0x58
cmd/compile/internal/gc.(*Escape).walkFunc(0xc0000f2210, 0xc0002e2160)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:204 +0x78
cmd/compile/internal/gc.escapeFuncs(0xc0000b6450, 0x1, 0x1, 0xc0002e4900)
/home/jeff/gotip/src/cmd/compile/internal/gc/escape.go:145 +0x117
cmd/compile/internal/gc.(*bottomUpVisitor).visit(0xc0003497a8, 0xc0002e2160, 0xbf402d1f18dba43e)
/home/jeff/gotip/src/cmd/compile/internal/gc/scc.go:118 +0x295
cmd/compile/internal/gc.visitBottomUp(0xc000094a20, 0x2, 0x2, 0xe5b258)
/home/jeff/gotip/src/cmd/compile/internal/gc/scc.go:58 +0x95
cmd/compile/internal/gc.escapes(...)
/home/jeff/gotip/src/cmd/compile/internal/gc/esc.go:49
cmd/compile/internal/gc.Main(0xe5b0c8)
/home/jeff/gotip/src/cmd/compile/internal/gc/main.go:646 +0x2f42
main.main()
/home/jeff/gotip/src/cmd/compile/main.go:51 +0xac
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
[-]cmd/gc: internal compiler error: unexpected type uint for 1[/-][+]cmd/compile: internal compiler error: unexpected type uint for 1[/+]agnivade commentedon Jul 6, 2019
Marked as release blocker since this is a regression.
@randall77
agnivade commentedon Jul 6, 2019
Bisected to 996a687
It passes with
-gcflags=all=-newescape=false
@mdempsky @dr2chase
mdempsky commentedon Jul 6, 2019
Thanks for the easy repro and bisection, @zeebo @agnivade.
I think the fix is in
unsafeValue
, forOLSH
andORSH
nodes we should calldiscard(n.Right)
instead ofunsafeValue(n.Right)
.gopherbot commentedon Jul 7, 2019
Change https://golang.org/cl/185039 mentions this issue:
cmd/compile: fix unsafeValue handles OLSH/ORSH wrong