klauspost / reedsolomon

Reed-Solomon Erasure Coding in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slice bounds out of range [6400:3200] in codeSomeShardsAVXP

ChrisSchinnerl opened this issue · comments

I've been reliably encountering the following (nondeterministic) panic in codeSomeShardsAVXP upon reconstructing data with 10 data shards and 20 parity shards.

panic: runtime error: slice bounds out of range [6400:3200]

goroutine 1 [running]:
github.com/klauspost/reedsolomon.(*reedSolomon).codeSomeShardsAVXP(0xc000018380, {0xc000120780, 0x14, 0x14}, {0xc00375b000, 0xa, 0x2a}, {0xc0001205a0, 0xf, 0x14}, ...)
        /go/pkg/mod/github.com/klauspost/reedsolomon@v1.11.6/reedsolomon.go:1035 +0xb05
github.com/klauspost/reedsolomon.(*reedSolomon).codeSomeShardsP(0xc000018380, {0xc000120780?, 0x14, 0x14}, {0xc00375b000?, 0xa, 0x2a}, {0xc0001205a0, 0xf, 0x14}, ...)
        /go/pkg/mod/github.com/klauspost/reedsolomon@v1.11.6/reedsolomon.go:903 +0x2d2
github.com/klauspost/reedsolomon.(*reedSolomon).codeSomeShards(0x10?, {0xc000120780?, 0xa?, 0xa?}, {0xc00375b000?, 0x4e1465?, 0xc0000120f0?}, {0xc0001205a0, 0xf, 0x14}, ...)
        /go/pkg/mod/github.com/klauspost/reedsolomon@v1.11.6/reedsolomon.go:794 +0x498
github.com/klauspost/reedsolomon.(*reedSolomon).reconstruct(0xc000018380, {0xc00375b000, 0x1e, 0x2a}, 0x0, {0x0, 0x0, 0x0?})
        /go/pkg/mod/github.com/klauspost/reedsolomon@v1.11.6/reedsolomon.go:1534 +0x8e5
github.com/klauspost/reedsolomon.(*reedSolomon).Reconstruct(0xa?, {0xc00375b000?, 0x0?, 0x0?})
        /go/pkg/mod/github.com/klauspost/reedsolomon@v1.11.6/reedsolomon.go:1341 +0x29
main.main()

This file contains an example of the shards passed to Reconstruct and can be used with the following code to reproduce the panic on a machine with AVXP support. It contains a json-encoded [][]byte with 10 4MiB shards and 20 empty ones.

func main() {
	for i := 0; i < 1000; i++ {
		fmt.Println("i", i)

		data, err := ioutil.ReadFile("f196a06267bd17cba44284f62e08da6b.json")
		if err != nil {
			os.Exit(1)
		}

		var shards [][]byte
		if err := json.Unmarshal(data, &shards); err != nil {
			os.Exit(1)
		}

		rsc, _ := reedsolomon.New(10, 20)
		if err := rsc.Reconstruct(shards); err != nil {
			os.Exit(1)
		}
	}
}

Additional Info:

  • Disabling AVX bypasses the bug
  • The processor used is an AMD Ryzen 7 5700X 8-Core

Yes, that is indeed strange. I've reproduced it and I will investigate.

Thanks a lot for looking into this so quickly!

No worries. When CI tests complete I will make a new release.

@ChrisSchinnerl v1.11.7 released.