Skip to content

cmd/compile: compiler crash during typecheking on len variable #27803

Closed
@kempeng

Description

@kempeng

Please answer these questions before submitting your issue. Thanks!

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

go version go1.11 windows/amd64

Does this issue reproduce with the latest release?

yes

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

PS C:\Users\geert\go\src\gnarb\alerter> go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\geert\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\geert\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\geert\AppData\Local\Temp\go-build068033874=/tmp/go-build -gno-record-gcc-switches

What did you do?

try to compile a new piece of code

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
I created a new function:

//NewMaps allocates the ResultItem maps
func (r *ResultItem) NewMaps(len int) {
...
}

What did you expect to see?

the go compile to compile the code (go compiler in powershell as integrated terminal in VSC)

What did you see instead?

PS C:\Users\geert\go\src\gnarb\alerter> go build

gnarb/chain

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x70 pc=0xb94675]

goroutine 1 [running]:
cmd/compile/internal/gc.typecheck1(0xc0006ad100, 0x2, 0x9f1f00000000b)
c:/go/src/cmd/compile/internal/gc/typecheck.go:1270 +0x3ed5
cmd/compile/internal/gc.typecheck(0xc0006ad100, 0x2, 0x0)
c:/go/src/cmd/compile/internal/gc/typecheck.go:238 +0x6b4
cmd/compile/internal/gc.typecheck1(0xc0006ad280, 0x2, 0xc0006a63c0)
c:/go/src/cmd/compile/internal/gc/typecheck.go:584 +0x2c91
cmd/compile/internal/gc.typecheck(0xc0006ad280, 0x2, 0x0)
c:/go/src/cmd/compile/internal/gc/typecheck.go:238 +0x6b4
cmd/compile/internal/gc.typecheck1(0xc0006ad080, 0x1, 0xc0006abd80)
c:/go/src/cmd/compile/internal/gc/typecheck.go:2051 +0xab00
cmd/compile/internal/gc.typecheck(0xc0006ad080, 0x1, 0xba7d56)
c:/go/src/cmd/compile/internal/gc/typecheck.go:238 +0x6b4
cmd/compile/internal/gc.typecheckslice(0xc0006a0aa0, 0x4, 0x4, 0x1)
c:/go/src/cmd/compile/internal/gc/typecheck.go:68 +0x57
cmd/compile/internal/gc.Main(0xcdea30)
c:/go/src/cmd/compile/internal/gc/main.go:518 +0x20d0
main.main()
c:/go/src/cmd/compile/main.go:51 +0x9d

Renaming NewMaps in the COMMENT resolved the runtime error:
//NewAMaps allocate the ResultItem maps
func (r *ResultItem) NewMaps(len int) {
...
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions