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: ICE in SSA when make is invoked with negative value instead of runtime panic about "len out of range" #36259

Closed
hideki1234 opened this issue Dec 24, 2019 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hideki1234
Copy link

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

$ go version
go version go1.13.5 windows/amd64

Does this issue reproduce with the latest release?

Yes, it does

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

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=D:\Users\hidek\AppData\Local\go-build
set GOENV=D:\Users\hidek\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\Users\hidek\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\Users\hidek\bin\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Users\hidek\bin\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=D:\Users\hidek\AppData\Local\Temp\go-build088172418=/tmp/go-build -gno-record-gcc-switches

What did you do?

I compiled the code below:

package main

import (
    "fmt"
)

func rotate(s []int, m int) {
    l := len(s)
    m = m % l
    buf := make([]int, m)

    copy(buf, s)
    copy(s, s[m:])
    copy(s[l-m:], buf)
}

func testRotate() {
    a0 := [...]int{1,2,3,4,5}
    fmt.Println(a0)

    rotate(a0[:], 1)
    fmt.Println(a0)

    rotate(a0[:], -3)
    fmt.Println(a0)
}

func main() {
    testRotate()
}

What did you expect to see?

rotate(a0[:], -3) is unsafe because it can result in calling make with a negative value. So I expected a runtime error or a meaningful compile error/warning message.

What did you see instead?

I got an internal compiler error:

# command-line-arguments
.\ex4-4.go:21:11: internal compiler error: 'testRotate': not lowered: v281, Move SSA UNSAFEPTR PTR SSA

Please file a bug report including a short program that triggers the error.
https://golang.org/issue/new

@gopherbot
Copy link

Change https://golang.org/cl/212405 mentions this issue: cmd/compile: avoid memmove -> SSA move rewrite when size is negative

@odeke-em odeke-em added this to the Go1.15 milestone Dec 24, 2019
@odeke-em odeke-em changed the title Internal compiler error cmd/compile: ICE in SSA when make is invoked with negative value instead of runtime panic about "len out of range" Dec 24, 2019
@cagedmantis cagedmantis added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 2, 2020
@golang golang locked and limited conversation to collaborators Feb 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants