Skip to content

gccgo: runtime panic with slice trick "delete" #23433

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

Closed
quasilyte opened this issue Jan 12, 2018 · 2 comments
Closed

gccgo: runtime panic with slice trick "delete" #23433

quasilyte opened this issue Jan 12, 2018 · 2 comments
Milestone

Comments

@quasilyte
Copy link
Contributor

quasilyte commented Jan 12, 2018

$ go version 
go version go1.8.1 linux/amd64

$ gccgo --version
gccgo (GCC) 7.2.0

Given the code slice_delete.go:

package main

import "fmt"

func main() {
    xs := []int{0,1,2,3,4}
    i := 2
    xs, xs[len(xs)-1] = append(xs[:i], xs[i+1:]...), 0
    fmt.Println(xs)
}

Run with 6g/GC:

$ go run slice_delete.go
[0 1 3 4]

Run with GCCGO:

$ go run -compiler gccgo slice_delete.go
panic: runtime error: index out of range

goroutine 16 [running]:
runtime.gopanic
	../../../src/libgo/go/runtime/panic.go:493
runtime_panicstring
	../../../src/libgo/runtime/panic.c:34
main.main
	/home/quasilyte/CODE/go/gccgo/slice_delete.go:8
runtime_main
	../../../src/libgo/runtime/proc.c:606
exit status 2

Also reproducible in this way:

$ gccgo slice_delete.go -o bin && ./bin

Found on stack overflow: delete-element-from-slice-difference-gccgo-vs-gc.

Most likely evaluation order mismatches here.

@gopherbot gopherbot added this to the Gccgo milestone Jan 12, 2018
@ianlancetaylor
Copy link
Contributor

I'm basically sure that gccgo is correct here, and the gc toolchain is wrong. Closing as dup of #23188.

@odeke-em
Copy link
Member

@ianlancetaylor I'll hit the close button for you, as alluded to in your comment.

@golang golang locked and limited conversation to collaborators Jan 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants