Skip to content

cmd/compile: SEGV in go 1.8 compiler (gc.typecheck1) with go build #19323

Closed

Description

@bstarynk

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

  1. changed the title [-]SEGV in go 1.8 compiler (gc.typecheck1) with go build[/-] [+]cmd/compile: SEGV in go 1.8 compiler (gc.typecheck1) with go build[/+] on Feb 28, 2017
  2. added this to the Go1.8.1 milestone on Feb 28, 2017
  3. ianlancetaylor commented on Feb 28, 2017

    @ianlancetaylor
    Contributor
  4. bstarynk commented on Feb 28, 2017

    @bstarynk
    Author

    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

  5. ianlancetaylor commented on Feb 28, 2017

    @ianlancetaylor
    Contributor

    @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

    sort.Sort(ordSliceObptr(coparr))[:l-nbnil]
    

    The Go function sort.Sort does 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:

    package p
    
    import "sort"
    
    func F(a []string) {
    	sort.Strings(a)[:]
    }
    
  6. josharian commented on Feb 28, 2017

    @josharian
    Contributor

    On it.

  7. gopherbot commented on Feb 28, 2017

    @gopherbot
    Contributor

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

  8. added 2 commits that reference this issue on Mar 1, 2017
    f8f0361
    4bb9e1a
  9. bstarynk commented on Mar 2, 2017

    @bstarynk
    Author

    Thanks a lot for being so responsive.

  10. modified the milestones: Go1.9, Go1.8.1 on Mar 21, 2017
  11. gopherbot commented on Apr 5, 2017

    @gopherbot
    Contributor

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

  12. added a commit that references this issue on Apr 5, 2017
    752b8b7
  13. locked and limited conversation to collaborators on Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions