Repository navigation
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.8 linux/amd64
What operating system and processor architecture are you using (go env)?
Linux/x86-64
Debian/Sid/x86-64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/ssdhome/basile/mygoworkspace:/ssdhome/basile/monimelt"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build617532280=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
If possible, provide a recipe for reproducing the error.
For some reason, I am not able to upload the faulty tarball via this interface.
Uploading monimelt-go-segv.tar.gz…
But I have installed that gzipped tar archive on http://gcc-melt.org/monimelt-go-segv.tar.gz
Its md5sum is c1036d5473fa30a3b23dbb72e6f6389f
It is a small file of 19234 bytes (less than twenty kilobytes)
and it is exactly the commit bstarynk/monimelt@507be38
Extract it into some directory monimelt-go-segv
then the three commands
export GOPATH=$PWD/monimelt-go-segv
cd monimelt-go-segv
go build src/monimelt.go
gives (in a reproducible fashion)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x998773]goroutine 1 [running]:
cmd/compile/internal/gc.typecheck1(0xc42050d320, 0x1, 0xc42050cab0)
/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:1122 +0xa2c3
cmd/compile/internal/gc.typecheck(0xc42050d320, 0x1, 0xc42050cab0)
/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:188 +0x608
cmd/compile/internal/gc.typecheckslice(0xc4200aef80, 0xd, 0x10, 0x1)
/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:49 +0x4e
cmd/compile/internal/gc.Main()
/usr/local/go/src/cmd/compile/internal/gc/main.go:374 +0x1938
main.main()
/usr/local/go/src/cmd/compile/main.go:50 +0xfe
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
I am a newbie, perhaps making newbie mistakes. I am expecting compiler error messages, not SEGV
What did you see instead?
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x998773]
and the shown backtrace is indeed inside the Go compiler & runtime.
Activity
[-]SEGV in go 1.8 compiler (gc.typecheck1) with go build[/-][+]cmd/compile: SEGV in go 1.8 compiler (gc.typecheck1) with go build[/+]ianlancetaylor commentedon Feb 28, 2017
CC @randall77 @josharian @dr2chase
bstarynk commentedon Feb 28, 2017
Ian and others, are you able to get the gzipped archive?
You should also be able to fetch it with
wget http://gcc-melt.org/monimelt-go-segv.tar.gz
ianlancetaylor commentedon Feb 28, 2017
@bstarynk Yes, I was able to retrieve it, and I was able to recreate the problem.
It's a crash-on-invalid. The crashing line is
The Go function
sort.Sortdoes not return anything. When you give it a slice, it sorts the slice in place. It doesn't return a sorted slice. So you are trying to slice a missing expression. The bug is that the compiler is crashing rather than reporting an error.Here is a smaller case that recreates the problem:
josharian commentedon Feb 28, 2017
On it.
gopherbot commentedon Feb 28, 2017
CL https://golang.org/cl/37584 mentions this issue.
cmd/compile: don't crash when slicing expression without type
cmd/compile: don't crash when slicing non-slice
bstarynk commentedon Mar 2, 2017
Thanks a lot for being so responsive.
gopherbot commentedon Apr 5, 2017
CL https://golang.org/cl/39601 mentions this issue.
[release-branch.go1.8] cmd/compile: don't crash when slicing non-slice