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

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

Closed
Quasilyte opened this Issue Jan 12, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@Quasilyte
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

This comment has been minimized.

Show comment
Hide comment
@ianlancetaylor

ianlancetaylor Jan 12, 2018

Contributor

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

Contributor

ianlancetaylor commented Jan 12, 2018

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

@odeke-em

This comment has been minimized.

Show comment
Hide comment
@odeke-em

odeke-em Jan 14, 2018

Member

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

Member

odeke-em commented Jan 14, 2018

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

@odeke-em odeke-em closed this Jan 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment